Added code to generate the default voices (#144)
This commit is contained in:
@@ -45,7 +45,8 @@
|
|||||||
<p class="text-xs text-gray-500 mt-1">
|
<p class="text-xs text-gray-500 mt-1">
|
||||||
Supports: http://, https://, or hf:// URLs.<br>
|
Supports: http://, https://, or hf:// URLs.<br>
|
||||||
You can also use predefined voices:<br>
|
You can also use predefined voices:<br>
|
||||||
"alba", "marius", "javert", "jean", "fantine", "cosette", "eponine", "azelma".
|
"alba", "anna", "azelma", "bill_boerst", "caro_davy", "charles", "eponine", "eve",
|
||||||
|
"fantine", "george", "jane", "jean", "mary", "michael", "paul", "peter_yearsley", "stuart_bell", "vera".
|
||||||
<br/>
|
<br/>
|
||||||
You can find more voices in our
|
You can find more voices in our
|
||||||
<a
|
<a
|
||||||
|
|||||||
@@ -11,11 +11,34 @@ from torch import nn
|
|||||||
|
|
||||||
PROJECT_ROOT = Path(__file__).parent.parent.parent
|
PROJECT_ROOT = Path(__file__).parent.parent.parent
|
||||||
|
|
||||||
_voices_names = ["alba", "marius", "javert", "jean", "fantine", "cosette", "eponine", "azelma"]
|
_ORIGINS_OF_PREDEFINED_VOICES = {
|
||||||
|
"cosette": "hf://kyutai/tts-voices/expresso/ex04-ex02_confused_001_channel1_499s.wav",
|
||||||
|
"marius": "hf://kyutai/tts-voices/voice-donations/Selfie.wav",
|
||||||
|
"javert": "hf://kyutai/tts-voices/voice-donations/Butter.wav",
|
||||||
|
"alba": "hf://kyutai/tts-voices/alba-mackenna/casual.wav",
|
||||||
|
"jean": "hf://kyutai/tts-voices/ears/p010/freeform_speech_01_enhanced.wav",
|
||||||
|
"anna": "hf://kyutai/tts-voices/vctk/p228_023_enhanced.wav",
|
||||||
|
"vera": "hf://kyutai/tts-voices/vctk/p229_023_enhanced.wav",
|
||||||
|
"fantine": "hf://kyutai/tts-voices/vctk/p244_023_enhanced.wav",
|
||||||
|
"charles": "hf://kyutai/tts-voices/vctk/p254_023_enhanced.wav",
|
||||||
|
"paul": "hf://kyutai/tts-voices/vctk/p259_023_enhanced.wav",
|
||||||
|
"eponine": "hf://kyutai/tts-voices/vctk/p262_023_enhanced.wav",
|
||||||
|
"azelma": "hf://kyutai/tts-voices/vctk/p303_023_enhanced.wav",
|
||||||
|
"george": "hf://kyutai/tts-voices/vctk/p315_023_enhanced.wav",
|
||||||
|
"mary": "hf://kyutai/tts-voices/vctk/p333_023_enhanced.wav",
|
||||||
|
"jane": "hf://kyutai/tts-voices/vctk/p339_023_enhanced.wav",
|
||||||
|
"michael": "hf://kyutai/tts-voices/vctk/p360_023_enhanced.wav",
|
||||||
|
"eve": "hf://kyutai/tts-voices/vctk/p361_023_enhanced.wav",
|
||||||
|
"bill_boerst": "hf://kyutai/tts-voices/voice-zero/bill_boerst.wav",
|
||||||
|
"peter_yearsley": "hf://kyutai/tts-voices/voice-zero/peter_yearsley.wav",
|
||||||
|
"stuart_bell": "hf://kyutai/tts-voices/voice-zero/stuart_bell.wav",
|
||||||
|
"caro_davy": "hf://kyutai/tts-voices/voice-zero/caro_davy.wav",
|
||||||
|
}
|
||||||
|
|
||||||
PREDEFINED_VOICES = {
|
PREDEFINED_VOICES = {
|
||||||
# don't forget to change this
|
# don't forget to change this
|
||||||
x: f"hf://kyutai/pocket-tts-without-voice-cloning/embeddings_v2/{x}.safetensors@2578fed2380333b621689eaed6fe144cf69dfeb3"
|
x: f"hf://kyutai/pocket-tts-without-voice-cloning/embeddings_v3/{x}.safetensors@075c0abfe7e41450521b0200b5168cfbc16bc77b"
|
||||||
for x in _voices_names
|
for x in _ORIGINS_OF_PREDEFINED_VOICES
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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()
|
||||||
|
)
|
||||||
@@ -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"
|
|
||||||
Reference in New Issue
Block a user