malek-messaoudii commited on
Commit
209f7bb
·
1 Parent(s): d43ba60

Update stt_service.py

Browse files
Files changed (1) hide show
  1. services/stt_service.py +12 -12
services/stt_service.py CHANGED
@@ -1,13 +1,13 @@
1
- import os
2
- from groq import Groq
3
- from config import client
4
 
5
- def speech_to_text(file_path: str):
6
- with open(file_path, "rb") as f:
7
- transcription = client.audio.transcriptions.create(
8
- file=(file_path, f.read()),
9
- model="whisper-large-v3-turbo",
10
- temperature=0,
11
- response_format="verbose_json"
12
- )
13
- return transcription.text
 
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", "")