Added code to generate the default voices (#144)

This commit is contained in:
Gabriel de Marmiesse
2026-03-12 18:12:47 +01:00
committed by GitHub
parent 5df2f4c383
commit 25e1b673cd
4 changed files with 51 additions and 30 deletions
+23
View File
@@ -0,0 +1,23 @@
import scipy.io.wavfile
from pocket_tts import TTSModel, export_model_state
from pocket_tts.utils.utils import _ORIGINS_OF_PREDEFINED_VOICES
model = TTSModel.load_model()
for voice_name, voice_origin in _ORIGINS_OF_PREDEFINED_VOICES.items():
print(f"Processing voice: {voice_name} from origin: {voice_origin}")
# Export a voice state for fast loading later
model_state = model.get_state_for_audio_prompt(voice_origin)
export_model_state(model_state, f"./built-in-voices/{voice_name}.safetensors")
model_state_copy = model.get_state_for_audio_prompt(
f"./built-in-voices/{voice_name}.safetensors"
)
audio = model.generate_audio(
model_state_copy, "Hello, it's a good day, isn't it? I hope you are doing well."
)
scipy.io.wavfile.write(
f"./built-in-voices-generated/{voice_name}.wav", model.sample_rate, audio.numpy()
)
-26
View File
@@ -1,26 +0,0 @@
#!/bin/bash
set -ex
# Generate safetensors files for all default voices
OUTPUT_DIR="${1:-./default_voices}"
mkdir -p "$OUTPUT_DIR"
# Default voices with their Hugging Face paths
# The marius voice can benefit from a bit of cleaning
declare -A voices=(
["alba"]="hf://kyutai/tts-voices/alba-mackenna/casual.wav"
["marius"]="hf://kyutai/tts-voices/voice-donations/Selfie.wav"
["javert"]="hf://kyutai/tts-voices/voice-donations/Butter.wav"
["jean"]="hf://kyutai/tts-voices/ears/p010/freeform_speech_01.wav"
["fantine"]="hf://kyutai/tts-voices/vctk/p244_023.wav"
["cosette"]="hf://kyutai/tts-voices/expresso/ex04-ex02_confused_001_channel1_499s.wav"
["eponine"]="hf://kyutai/tts-voices/vctk/p262_023.wav"
["azelma"]="hf://kyutai/tts-voices/vctk/p303_023.wav"
)
for voice in "${!voices[@]}"; do
echo "Exporting voice: $voice"
uv run pocket-tts export-voice "${voices[$voice]}" "$OUTPUT_DIR/$voice.safetensors"
done
echo "Done! Voice files saved to $OUTPUT_DIR"