malek-messaoudii commited on
Commit
14f424f
·
1 Parent(s): 9aa985d

Update stt_service.py

Browse files
Files changed (1) hide show
  1. 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
- # Wrap audio bytes correctly for Gemini
11
- contents = [types.File(data=audio_bytes, mime_type="audio/wav")]
12
 
13
  response = client.models.generate_content(
14
  model="gemini-2.5-flash",
15
- contents=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