File size: 667 Bytes
9a13466
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import sounddevice as sd          # records and plays audio (pure Python + tiny C)
import soundfile as sf            # saves audio to .wav files
import whisper                    # OpenAI's speech-to-text (tiny model = CPU-friendly)
from piper.voice import PiperVoice  # super natural text-to-speech
import tempfile                   # creates temporary files that auto-delete
import os

print("Loading whisper model")
whisper_model = whisper.load_model("/models/whisper/tiny.pt")
print("Model ready")

print("Loading...")
piper_voice = PiperVoice.load(
    "/models/piper/ryan-high.onnx",
    config_path="/models/piper/ryan-high-onnx.json"
)
print("Piper ready...")