malek-messaoudii
commited on
Commit
·
14f424f
1
Parent(s):
9aa985d
Update stt_service.py
Browse files- services/stt_service.py +3 -6
services/stt_service.py
CHANGED
|
@@ -2,17 +2,14 @@ from services.gemini_client import get_gemini_client
|
|
| 2 |
from google.genai import types
|
| 3 |
|
| 4 |
async def speech_to_text(audio_bytes: bytes) -> str:
|
| 5 |
-
"""
|
| 6 |
-
Convert speech audio (bytes) to text using Gemini API
|
| 7 |
-
"""
|
| 8 |
client = get_gemini_client()
|
| 9 |
|
| 10 |
-
#
|
| 11 |
-
|
| 12 |
|
| 13 |
response = client.models.generate_content(
|
| 14 |
model="gemini-2.5-flash",
|
| 15 |
-
contents=
|
| 16 |
)
|
| 17 |
|
| 18 |
return response.text
|
|
|
|
| 2 |
from google.genai import types
|
| 3 |
|
| 4 |
async def speech_to_text(audio_bytes: bytes) -> str:
|
|
|
|
|
|
|
|
|
|
| 5 |
client = get_gemini_client()
|
| 6 |
|
| 7 |
+
# Correctly wrap audio bytes using types.File
|
| 8 |
+
audio_file = types.File(data=audio_bytes, mime_type="audio/wav")
|
| 9 |
|
| 10 |
response = client.models.generate_content(
|
| 11 |
model="gemini-2.5-flash",
|
| 12 |
+
contents=[audio_file] # <-- pass as a list of types.File
|
| 13 |
)
|
| 14 |
|
| 15 |
return response.text
|