Spaces:
Sleeping
Sleeping
import openai | |
import io | |
# Use async client for better performance | |
client = openai.AsyncOpenAI() | |
async def transcribe_audio(audio_bytes: bytes, file_ext: str = ".m4a") -> str: | |
file_obj = io.BytesIO(audio_bytes) | |
file_obj.name = "audio" + file_ext | |
# Add language hint and prompt for faster processing | |
transcript_resp = await client.audio.transcriptions.create( | |
model="whisper-1", | |
file=file_obj, | |
response_format="text", | |
language="en", # Hint for faster processing | |
prompt="This is a conversation about wellness and mental health." # Context helps | |
) | |
return transcript_resp | |