xvectors
Browse files
app.py
CHANGED
@@ -10,17 +10,10 @@ processor = SpeechT5Processor.from_pretrained(model_name)
|
|
10 |
model = SpeechT5ForTextToSpeech.from_pretrained("emirhanbilgic/speecht5_finetuned_emirhan_tr")
|
11 |
vocoder = SpeechT5HifiGan.from_pretrained("microsoft/speecht5_hifigan")
|
12 |
|
13 |
-
# Load the Turkish
|
14 |
-
|
|
|
15 |
|
16 |
-
# Get an example text and its corresponding audio
|
17 |
-
example_item = turkish_dataset[0]
|
18 |
-
example_text = example_item['text']
|
19 |
-
example_audio = example_item['audio']['array']
|
20 |
-
|
21 |
-
# Create speaker embedding from the example audio
|
22 |
-
with torch.no_grad():
|
23 |
-
speaker_embeddings = model.get_speaker_embeddings(torch.tensor(example_audio).unsqueeze(0))
|
24 |
|
25 |
def text_to_speech(text):
|
26 |
inputs = processor(text=text, return_tensors="pt")
|
@@ -31,7 +24,7 @@ def text_to_speech(text):
|
|
31 |
# Create Gradio interface
|
32 |
iface = gr.Interface(
|
33 |
fn=text_to_speech,
|
34 |
-
inputs=gr.Textbox(label="Enter Turkish text to convert to speech", value=
|
35 |
outputs=gr.Audio(label="Generated Speech"),
|
36 |
title="Turkish SpeechT5 Text-to-Speech Demo",
|
37 |
description="Enter Turkish text and listen to the generated speech using the fine-tuned SpeechT5 model."
|
|
|
10 |
model = SpeechT5ForTextToSpeech.from_pretrained("emirhanbilgic/speecht5_finetuned_emirhan_tr")
|
11 |
vocoder = SpeechT5HifiGan.from_pretrained("microsoft/speecht5_hifigan")
|
12 |
|
13 |
+
# Load speaker embeddings (using the same as before, as it's not clear if a specific embedding is needed for the Turkish model)
|
14 |
+
embeddings_dataset = load_dataset("Matthijs/cmu-arctic-xvectors", split="validation")
|
15 |
+
speaker_embeddings = torch.tensor(embeddings_dataset[7306]["xvector"]).unsqueeze(0)
|
16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
def text_to_speech(text):
|
19 |
inputs = processor(text=text, return_tensors="pt")
|
|
|
24 |
# Create Gradio interface
|
25 |
iface = gr.Interface(
|
26 |
fn=text_to_speech,
|
27 |
+
inputs=gr.Textbox(label="Enter Turkish text to convert to speech", value="Yapay zekayı seviyorum."),
|
28 |
outputs=gr.Audio(label="Generated Speech"),
|
29 |
title="Turkish SpeechT5 Text-to-Speech Demo",
|
30 |
description="Enter Turkish text and listen to the generated speech using the fine-tuned SpeechT5 model."
|