updated groq api
Browse files- app/stt.py +14 -5
app/stt.py
CHANGED
|
@@ -21,19 +21,28 @@ class AudioProcessor:
|
|
| 21 |
"""
|
| 22 |
Initialize the AudioProcessor by loading configuration and setting up the Groq client.
|
| 23 |
"""
|
|
|
|
| 24 |
# Compute the absolute path to the config file located at <project_root>/config/config.yml.
|
| 25 |
base_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
|
| 26 |
config_path = os.path.join(base_dir, "config", "config.yml")
|
| 27 |
|
| 28 |
-
# Load the configuration from the YAML file
|
| 29 |
with open(config_path, "r") as file:
|
| 30 |
self.config_data = yaml.safe_load(file)
|
| 31 |
|
| 32 |
-
# Access
|
| 33 |
-
self.groq_api_key =
|
| 34 |
-
self.groq_model = self.config_data["groq"]["model"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
-
# Initialize the Groq client
|
| 37 |
self.groq_client = Groq(api_key=self.groq_api_key)
|
| 38 |
|
| 39 |
# Store default audio settings from the config.
|
|
|
|
| 21 |
"""
|
| 22 |
Initialize the AudioProcessor by loading configuration and setting up the Groq client.
|
| 23 |
"""
|
| 24 |
+
|
| 25 |
# Compute the absolute path to the config file located at <project_root>/config/config.yml.
|
| 26 |
base_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
|
| 27 |
config_path = os.path.join(base_dir, "config", "config.yml")
|
| 28 |
|
| 29 |
+
# Load the configuration from the YAML file
|
| 30 |
with open(config_path, "r") as file:
|
| 31 |
self.config_data = yaml.safe_load(file)
|
| 32 |
|
| 33 |
+
# Access Groq settings - Get API key from Hugging Face secrets
|
| 34 |
+
self.groq_api_key = os.getenv("GROQ_API_KEY") # From environment variables
|
| 35 |
+
self.groq_model = self.config_data["groq"]["model"] # Keep model name in config
|
| 36 |
+
|
| 37 |
+
# Validate configuration
|
| 38 |
+
if not self.groq_api_key:
|
| 39 |
+
raise ValueError("Groq API key not found in environment variables. "
|
| 40 |
+
"Set GROQ_API_KEY in Hugging Face secrets.")
|
| 41 |
+
|
| 42 |
+
if not self.groq_model:
|
| 43 |
+
raise ValueError("Groq model not configured in config.yml")
|
| 44 |
|
| 45 |
+
# Initialize the Groq client
|
| 46 |
self.groq_client = Groq(api_key=self.groq_api_key)
|
| 47 |
|
| 48 |
# Store default audio settings from the config.
|