Transcribe Module¶
voice_agent.transcribe
¶
Whisper server client for audio transcription.
Sends audio data to whisper-server and returns transcription text.
TranscriptionError
¶
Bases: Exception
Raised when transcription fails.
Source code in src/voice_agent/transcribe.py
9 10 | |
transcribe(audio_data, whisper_url, timeout=60.0)
async
¶
Transcribe audio data using whisper-server.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
audio_data
|
bytes
|
Raw audio bytes (e.g., .oga format from Telegram). |
required |
whisper_url
|
str
|
URL of the whisper-server /transcribe endpoint. |
required |
timeout
|
float
|
Request timeout in seconds. |
60.0
|
Returns:
| Type | Description |
|---|---|
str
|
Transcribed text from the audio. |
Raises:
| Type | Description |
|---|---|
TranscriptionError
|
If the request fails or transcription is empty. |
Source code in src/voice_agent/transcribe.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | |