Examples
This section provides practical examples for using fmus-vox.
Simple Transcription
examples/simple_transcription.py
from fmus_vox import transcribe
# Transcribe an audio file
audio_file = "recording.wav"
text = transcribe(audio_file)
print(f"Transcription: {text}")
Text to Speech
examples/text_to_speech.py
from fmus_vox import Speaker
# Create a speaker
speaker = Speaker(voice="en-female-1")
# Generate speech
speaker.speak(
"Hello! Welcome to fmus-vox.",
output="welcome.wav"
)
Voice Assistant
examples/voice_assistant.py
from fmus_vox import VoiceApp
app = VoiceApp()
@app.on_wake("hey assistant")
def on_wake():
"""Handle wake word detection."""
print("Assistant activated!")
return True
@app.on_transcribe
def on_transcribe(text):
"""Handle user input."""
print(f"You said: {text}")
# Simple command processing
if "hello" in text.lower():
return "Hello! How can I help you?"
elif "time" in text.lower():
from datetime import datetime
return f"The time is {datetime.now().strftime('%H:%M')}"
else:
return "I didn't understand that."
if __name__ == "__main__":
app.run()
For more examples, see the examples/ directory in the repository.