examples.benchmark_audio¶
Audio benchmarks for vllm-mlx.
View the complete module source at #L1-L332.
API details¶
Each callable below includes its exact signature, type annotations, inputs, defaults, return contract, documented exceptions, implementation source, and parsed docstring sections when the source provides them.
examples.benchmark_audio
¶
Audio benchmarks for vllm-mlx.
Benchmarks STT (Speech-to-Text), TTS (Text-to-Speech), and audio processing.
examples.benchmark_audio.STT_MODELS
module-attribute
¶
STT_MODELS = [('mlx-community/whisper-tiny-mlx', 'whisper-tiny'), ('mlx-community/whisper-small-mlx', 'whisper-small'), ('mlx-community/whisper-medium-mlx', 'whisper-medium'), ('mlx-community/whisper-large-v3-mlx', 'whisper-large-v3'), ('mlx-community/whisper-large-v3-turbo', 'whisper-large-v3-turbo'), ('mlx-community/parakeet-tdt-0.6b-v2', 'parakeet-tdt-0.6b-v2'), ('mlx-community/parakeet-tdt-0.6b-v3', 'parakeet-tdt-0.6b-v3')]
examples.benchmark_audio.TTS_MODELS
module-attribute
¶
TTS_MODELS = [('mlx-community/Kokoro-82M-bf16', 'kokoro'), ('mlx-community/Kokoro-82M-4bit', 'kokoro-4bit')]
examples.benchmark_audio.TEST_TEXTS
module-attribute
¶
TEST_TEXTS = ['Hello, how are you today?', 'The quick brown fox jumps over the lazy dog. This is a test of text to speech synthesis.', 'In a world where technology advances rapidly, artificial intelligence has become an integral part of our daily lives. From voice assistants to autonomous vehicles, AI systems are transforming how we work, communicate, and live.']
examples.benchmark_audio.generate_test_audio
¶
Generate a simple test audio file using TTS.
Source code in examples/benchmark_audio.py
examples.benchmark_audio.benchmark_tts
¶
Benchmark TTS model.
Source code in examples/benchmark_audio.py
examples.benchmark_audio.get_audio_duration
¶
Get audio duration in seconds.
Source code in examples/benchmark_audio.py
examples.benchmark_audio.benchmark_stt
¶
Benchmark STT model.
Source code in examples/benchmark_audio.py
examples.benchmark_audio.check_whisper_backend
¶
Check whether the Whisper backend can be imported.
Returns:
-
–
(available: bool, reason: str)
Source code in examples/benchmark_audio.py
examples.benchmark_audio.run_tts_benchmarks
¶
Run all TTS benchmarks.
Source code in examples/benchmark_audio.py
examples.benchmark_audio.run_stt_benchmarks
¶
Run all STT benchmarks.
Source code in examples/benchmark_audio.py
examples.benchmark_audio.main
¶
Source code in examples/benchmark_audio.py
Complete contract reference¶
Expand any definition for its exact inputs, annotations, defaults, return contract, directly raised exceptions, source-grounded behavior, and immutable line link. This section includes private and nested definitions that ordinary API generators omit.
examples.benchmark_audio.generate_test_audio · function
Generate a simple test audio file using TTS.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
duration_seconds |
float |
no |
5.0 |
Optional positional or keyword input; defaults to 5.0. |
Returns
- Type:
str - Direct return expressions:
path
Exceptions and behavior
Function generate_test_audio calls np.linspace, int, np.sin, (audio * 32767).astype; returns path.
No direct raise statement appears in this definition.
examples.benchmark_audio.benchmark_tts · function
examples.benchmark_audio.benchmark_tts(model_name: str, alias: str, texts: list[str], voice: str = 'af_heart') -> not annotated
Benchmark TTS model.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
model_name |
str |
yes |
none |
Required positional or keyword input. |
alias |
str |
yes |
none |
Required positional or keyword input. |
texts |
list[str] |
yes |
none |
Required positional or keyword input. |
voice |
str |
no |
'af_heart' |
Optional positional or keyword input; defaults to 'af_heart'. |
Returns
- Type:
not annotated - Direct return expressions:
{'model': alias, 'load_time': load_time, 'avg_chars_per_sec': avg_chars_per_sec, 'avg_rtf': avg_rtf}
Exceptions and behavior
Function benchmark_tts calls print, time.time, TTSEngine, engine.load; returns {'model': alias, 'load_time': load_time, 'avg_chars_per_sec': avg_chars_per_sec, 'avg_rtf': avg_rtf}.
No direct raise statement appears in this definition.
examples.benchmark_audio.get_audio_duration · function
Get audio duration in seconds.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
audio_path |
str |
yes |
none |
Required positional or keyword input. |
Returns
- Type:
float - Direct return expressions:
frames / float(rate);float(result.stdout.strip());0.0
Exceptions and behavior
Function get_audio_duration calls audio_path.endswith, contextlib.closing, wave.open, f.getnframes; has 3 explicit return paths.
No direct raise statement appears in this definition.
examples.benchmark_audio.benchmark_stt · function
examples.benchmark_audio.benchmark_stt(model_name: str, alias: str, audio_path: str) -> not annotated
Benchmark STT model.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
model_name |
str |
yes |
none |
Required positional or keyword input. |
alias |
str |
yes |
none |
Required positional or keyword input. |
audio_path |
str |
yes |
none |
Required positional or keyword input. |
Returns
- Type:
not annotated - Direct return expressions:
{'model': alias, 'load_time': load_time, 'audio_duration': duration, 'trans_time': trans_time, 'rtf': rtf}
Exceptions and behavior
Function benchmark_stt calls print, get_audio_duration, time.time, STTEngine; returns {'model': alias, 'load_time': load_time, 'audio_duration': duration, 'trans_time': trans_time, 'rtf': rtf}.
No direct raise statement appears in this definition.
examples.benchmark_audio.check_whisper_backend · function
Check whether the Whisper backend can be imported.
Parameters
This callable has no explicit inputs.
Returns
- Type:
not annotated - Direct return expressions:
(True, '');(False, str(e))
Exceptions and behavior
Function check_whisper_backend calls str; has 2 explicit return paths.
No direct raise statement appears in this definition.
examples.benchmark_audio.run_tts_benchmarks · function
Run all TTS benchmarks.
Parameters
This callable has no explicit inputs.
Returns
- Type:
not annotated - Direct return expressions:
results
Exceptions and behavior
Function run_tts_benchmarks calls print, benchmark_tts, results.append; returns results.
No direct raise statement appears in this definition.
examples.benchmark_audio.run_stt_benchmarks · function
Run all STT benchmarks.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
audio_path |
str |
yes |
none |
Required positional or keyword input. |
Returns
- Type:
not annotated - Direct return expressions:
results
Exceptions and behavior
Function run_stt_benchmarks calls print, check_whisper_backend, alias.startswith, benchmark_stt; returns results.
No direct raise statement appears in this definition.
examples.benchmark_audio.main · function
Function main calls argparse.ArgumentParser, parser.add_argument, parser.parse_args, print.
Parameters
This callable has no explicit inputs.
Returns
- Type:
not annotated
Exceptions and behavior
Function main calls argparse.ArgumentParser, parser.add_argument, parser.parse_args, print.
No direct raise statement appears in this definition.
Complete symbol map¶
This map also includes private definitions and nested helpers. The signature column exposes every explicit input even when an internal helper has no dedicated parameter prose.
| Symbol | Kind | Signature and inputs | What it does | Source |
|---|---|---|---|---|
generate_test_audio |
function | generate_test_audio(duration_seconds: float = 5.0) -> str |
Generate a simple test audio file using TTS. | #L36-L61 |
benchmark_tts |
function | benchmark_tts(model_name: str, alias: str, texts: list[str], voice: str = 'af_heart') -> not annotated |
Benchmark TTS model. | #L64-L124 |
get_audio_duration |
function | get_audio_duration(audio_path: str) -> float |
Get audio duration in seconds. | #L127-L159 |
benchmark_stt |
function | benchmark_stt(model_name: str, alias: str, audio_path: str) -> not annotated |
Benchmark STT model. | #L162-L212 |
check_whisper_backend |
function | check_whisper_backend() -> not annotated |
Check whether the Whisper backend can be imported. | #L215-L227 |
run_tts_benchmarks |
function | run_tts_benchmarks() -> not annotated |
Run all TTS benchmarks. | #L230-L257 |
run_stt_benchmarks |
function | run_stt_benchmarks(audio_path: str) -> not annotated |
Run all STT benchmarks. | #L260-L295 |
main |
function | main() -> not annotated |
Function main calls argparse.ArgumentParser, parser.add_argument, parser.parse_args, print. |
#L298-L328 |