Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -16,19 +16,16 @@ tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2").to(device)
|
|
16 |
@spaces.GPU(enable_queue=True)
|
17 |
def clone(text, audio):
|
18 |
# Generowanie mowy
|
19 |
-
wav = tts.tts(text=text, speaker_wav=audio, language="pl")
|
20 |
|
21 |
# Konwersja do numpy array i zapisanie jako plik WAV
|
22 |
wav_np = np.array(wav)
|
23 |
wavfile.write("./output.wav", 24000, (wav_np * 32767).astype(np.int16))
|
24 |
|
25 |
-
# Uzyskanie informacji o fonemach
|
26 |
-
phonemes_info = tts.synthesizer.get_phonemes(text, language="pl")
|
27 |
-
|
28 |
# Przygotowanie informacji o fonemach
|
29 |
phonemes_data = []
|
30 |
cumulative_duration = 0
|
31 |
-
for phoneme, duration in
|
32 |
start_time = cumulative_duration
|
33 |
end_time = start_time + duration
|
34 |
phonemes_data.append({
|
@@ -60,4 +57,4 @@ iface = gr.Interface(
|
|
60 |
theme=gr.themes.Base(primary_hue="teal", secondary_hue="teal", neutral_hue="slate")
|
61 |
)
|
62 |
|
63 |
-
iface.launch(
|
|
|
16 |
@spaces.GPU(enable_queue=True)
|
17 |
def clone(text, audio):
|
18 |
# Generowanie mowy
|
19 |
+
wav, alignment, text_info, _ = tts.tts(text=text, speaker_wav=audio, language="pl", return_dict=True)
|
20 |
|
21 |
# Konwersja do numpy array i zapisanie jako plik WAV
|
22 |
wav_np = np.array(wav)
|
23 |
wavfile.write("./output.wav", 24000, (wav_np * 32767).astype(np.int16))
|
24 |
|
|
|
|
|
|
|
25 |
# Przygotowanie informacji o fonemach
|
26 |
phonemes_data = []
|
27 |
cumulative_duration = 0
|
28 |
+
for phoneme, duration in zip(text_info['phonemes'], alignment['durations']):
|
29 |
start_time = cumulative_duration
|
30 |
end_time = start_time + duration
|
31 |
phonemes_data.append({
|
|
|
57 |
theme=gr.themes.Base(primary_hue="teal", secondary_hue="teal", neutral_hue="slate")
|
58 |
)
|
59 |
|
60 |
+
iface.launch()
|