Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -14,23 +14,25 @@ tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2").to(device)
|
|
14 |
@spaces.GPU(enable_queue=True)
|
15 |
def clone(text, audio):
|
16 |
# Generowanie mowy
|
17 |
-
wav
|
18 |
|
19 |
# Zapisywanie pliku audio
|
20 |
tts.save_wav(wav, file_path="./output.wav")
|
21 |
|
|
|
|
|
|
|
22 |
# Przygotowanie informacji o fonemach
|
23 |
-
|
24 |
-
for phoneme,
|
25 |
-
|
26 |
"phoneme": phoneme,
|
27 |
-
"
|
28 |
-
"end": float(end)
|
29 |
})
|
30 |
|
31 |
# Zapisywanie informacji o fonemach do pliku JSON
|
32 |
with open("./phonemes_info.json", "w", encoding="utf-8") as f:
|
33 |
-
json.dump(
|
34 |
|
35 |
return "./output.wav", "./phonemes_info.json"
|
36 |
|
@@ -49,4 +51,4 @@ iface = gr.Interface(
|
|
49 |
theme=gr.themes.Base(primary_hue="teal", secondary_hue="teal", neutral_hue="slate")
|
50 |
)
|
51 |
|
52 |
-
iface.launch()
|
|
|
14 |
@spaces.GPU(enable_queue=True)
|
15 |
def clone(text, audio):
|
16 |
# Generowanie mowy
|
17 |
+
wav = tts.tts(text=text, speaker_wav=audio, language="pl")
|
18 |
|
19 |
# Zapisywanie pliku audio
|
20 |
tts.save_wav(wav, file_path="./output.wav")
|
21 |
|
22 |
+
# Uzyskanie informacji o fonemach
|
23 |
+
phonemes_info = tts.synthesizer.get_phonemes(text, language="pl")
|
24 |
+
|
25 |
# Przygotowanie informacji o fonemach
|
26 |
+
phonemes_data = []
|
27 |
+
for phoneme, duration in phonemes_info:
|
28 |
+
phonemes_data.append({
|
29 |
"phoneme": phoneme,
|
30 |
+
"duration": float(duration)
|
|
|
31 |
})
|
32 |
|
33 |
# Zapisywanie informacji o fonemach do pliku JSON
|
34 |
with open("./phonemes_info.json", "w", encoding="utf-8") as f:
|
35 |
+
json.dump(phonemes_data, f, ensure_ascii=False, indent=2)
|
36 |
|
37 |
return "./output.wav", "./phonemes_info.json"
|
38 |
|
|
|
51 |
theme=gr.themes.Base(primary_hue="teal", secondary_hue="teal", neutral_hue="slate")
|
52 |
)
|
53 |
|
54 |
+
iface.launch(share=True)
|