File size: 430 Bytes
209f7bb 4a13628 209f7bb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
# stt_service.py
import requests
from config import GROQ_API_KEY, GROQ_STT_MODEL
def speech_to_text(audio_file_path: str) -> str:
headers = {"Authorization": f"Bearer {GROQ_API_KEY}"}
files = {"file": open(audio_file_path, "rb")}
response = requests.post(
f"https://api.groq.ai/v1/models/{GROQ_STT_MODEL}/predict",
headers=headers,
files=files
)
return response.json().get("text", "")
|