Vinay15 commited on
Commit
bdbc025
·
verified ·
1 Parent(s): c1db09f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -5
app.py CHANGED
@@ -3,8 +3,8 @@ import torch
3
  from datasets import load_dataset
4
  from transformers import SpeechT5Processor, SpeechT5HifiGan, SpeechT5ForTextToSpeech
5
 
6
- # Load the fine-tuned model and vocoder for Italian from the new model ID
7
- model_id = "Vinay15/speecht5_finetuned_voxpopuli_it"
8
  model = SpeechT5ForTextToSpeech.from_pretrained(model_id)
9
  vocoder = SpeechT5HifiGan.from_pretrained("microsoft/speecht5_hifigan")
10
 
@@ -12,7 +12,7 @@ vocoder = SpeechT5HifiGan.from_pretrained("microsoft/speecht5_hifigan")
12
  embeddings_dataset = load_dataset("Matthijs/cmu-arctic-xvectors", split="validation")
13
  speaker_embeddings = torch.tensor(embeddings_dataset[7440]["xvector"]).unsqueeze(0)
14
 
15
- # Load processor for the new Italian model
16
  processor = SpeechT5Processor.from_pretrained(model_id)
17
 
18
  # Optional: Text cleanup for Italian-specific characters
@@ -27,7 +27,7 @@ replacements = [
27
 
28
  # Text-to-speech synthesis function
29
  def synthesize_speech(text):
30
- # Clean up text for Italian-specific accents
31
  for src, dst in replacements:
32
  text = text.replace(src, dst)
33
 
@@ -47,6 +47,20 @@ This demo generates speech in Italian using the fine-tuned SpeechT5 model from H
47
  The model is fine-tuned on the VoxPopuli Italian dataset.
48
  """
49
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  # Create Gradio interface
51
  interface = gr.Interface(
52
  fn=synthesize_speech,
@@ -54,7 +68,7 @@ interface = gr.Interface(
54
  outputs=gr.Audio(label="Generated Speech"),
55
  title=title,
56
  description=description,
57
- examples=["Questa è una dimostrazione di sintesi vocale in italiano."]
58
  )
59
 
60
  # Launch the interface
 
3
  from datasets import load_dataset
4
  from transformers import SpeechT5Processor, SpeechT5HifiGan, SpeechT5ForTextToSpeech
5
 
6
+ # Load the fine-tuned model and vocoder for Italian
7
+ model_id = "Sandiago21/speecht5_finetuned_voxpopuli_it"
8
  model = SpeechT5ForTextToSpeech.from_pretrained(model_id)
9
  vocoder = SpeechT5HifiGan.from_pretrained("microsoft/speecht5_hifigan")
10
 
 
12
  embeddings_dataset = load_dataset("Matthijs/cmu-arctic-xvectors", split="validation")
13
  speaker_embeddings = torch.tensor(embeddings_dataset[7440]["xvector"]).unsqueeze(0)
14
 
15
+ # Load processor for the Italian model
16
  processor = SpeechT5Processor.from_pretrained(model_id)
17
 
18
  # Optional: Text cleanup for Italian-specific characters
 
27
 
28
  # Text-to-speech synthesis function
29
  def synthesize_speech(text):
30
+ # Clean up text
31
  for src, dst in replacements:
32
  text = text.replace(src, dst)
33
 
 
47
  The model is fine-tuned on the VoxPopuli Italian dataset.
48
  """
49
 
50
+ # More examples of Italian text
51
+ examples = [
52
+ "Questa è una dimostrazione di sintesi vocale in italiano.",
53
+ "La tecnologia della sintesi vocale sta avanzando rapidamente.",
54
+ "Oggi il tempo è sereno con una leggera brezza.",
55
+ "Mi chiamo Maria e sto imparando a usare il Text-to-Speech.",
56
+ "L'intelligenza artificiale cambierà il futuro della comunicazione.",
57
+ "Benvenuti a Roma, la città eterna, ricca di storia e cultura.",
58
+ "Spero che questo modello di sintesi vocale possa essere utile per molte applicazioni.",
59
+ "La pizza è uno dei piatti italiani più famosi al mondo.",
60
+ "Il mare in estate è calmo e limpido.",
61
+ "L'inverno in montagna è freddo e coperto di neve."
62
+ ]
63
+
64
  # Create Gradio interface
65
  interface = gr.Interface(
66
  fn=synthesize_speech,
 
68
  outputs=gr.Audio(label="Generated Speech"),
69
  title=title,
70
  description=description,
71
+ examples=examples
72
  )
73
 
74
  # Launch the interface