Spaces:
Sleeping
Sleeping
File size: 640 Bytes
a3c7b61 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
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
|