21 lines
659 B
Python
21 lines
659 B
Python
import asyncio
|
|
from backend.tts_asr import _tts_sync_with_retry, _load_asr_pipeline_with_retry, _asr_pipeline
|
|
import base64
|
|
|
|
async def main():
|
|
text = "早上好"
|
|
print(f"Testing TTS with text: {text}")
|
|
audio_bytes, sr = await _tts_sync_with_retry(text, rate=1.0)
|
|
print(f"TTS generated {len(audio_bytes)} bytes of audio.")
|
|
|
|
print("Testing ASR...")
|
|
await _load_asr_pipeline_with_retry()
|
|
asr = _asr_pipeline
|
|
|
|
# Needs to process audio_bytes. ASR expects float32 numpy array or bytes?
|
|
# the pipeline takes bytes or dict with raw array
|
|
result = asr(audio_bytes)
|
|
print("ASR output:", result)
|
|
|
|
asyncio.run(main())
|