File size: 499 Bytes
73d4f3c 9aa985d c7fc3b6 73d4f3c 9aa985d 73d4f3c 9aa985d 73d4f3c 9aa985d 73d4f3c 9aa985d 91b1985 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
from services.gemini_client import get_gemini_client
from google.genai import types
async def speech_to_text(audio_bytes: bytes) -> str:
"""
Convert speech audio (bytes) to text using Gemini API
"""
client = get_gemini_client()
# Wrap audio bytes correctly for Gemini
contents = [types.File(data=audio_bytes, mime_type="audio/wav")]
response = client.models.generate_content(
model="gemini-2.5-flash",
contents=contents
)
return response.text
|