malek-messaoudii
commited on
Commit
·
209f7bb
1
Parent(s):
d43ba60
Update stt_service.py
Browse files- services/stt_service.py +12 -12
services/stt_service.py
CHANGED
|
@@ -1,13 +1,13 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
from config import
|
| 4 |
|
| 5 |
-
def speech_to_text(
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
return
|
|
|
|
| 1 |
+
# stt_service.py
|
| 2 |
+
import requests
|
| 3 |
+
from config import GROQ_API_KEY, GROQ_STT_MODEL
|
| 4 |
|
| 5 |
+
def speech_to_text(audio_file_path: str) -> str:
|
| 6 |
+
headers = {"Authorization": f"Bearer {GROQ_API_KEY}"}
|
| 7 |
+
files = {"file": open(audio_file_path, "rb")}
|
| 8 |
+
response = requests.post(
|
| 9 |
+
f"https://api.groq.ai/v1/models/{GROQ_STT_MODEL}/predict",
|
| 10 |
+
headers=headers,
|
| 11 |
+
files=files
|
| 12 |
+
)
|
| 13 |
+
return response.json().get("text", "")
|