Vinay15 commited on
Commit
9cfe01a
·
verified ·
1 Parent(s): 4778f50

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -7
app.py CHANGED
@@ -1,3 +1,7 @@
 
 
 
 
1
  import gradio as gr
2
  import json
3
  import torch
@@ -11,7 +15,7 @@ model = SpeechT5ForTextToSpeech.from_pretrained("microsoft/speecht5_tts")
11
  vocoder = SpeechT5HifiGan.from_pretrained("microsoft/speecht5_hifigan")
12
 
13
  # Load pronunciation dictionary from JSON file
14
- with open("pronunciation_dict.json", "r") as f:
15
  pronunciation_dict = json.load(f)
16
 
17
  # Function to preprocess the input text
@@ -41,12 +45,23 @@ def text_to_speech(input_text):
41
 
42
  return output_file
43
 
44
- # Step 5: Create Gradio interface
45
- iface = gr.Interface(fn=text_to_speech,
46
- inputs="text",
47
- outputs="audio",
48
- title="Text-to-Speech (TTS) Application",
49
- description="Enter text with technical jargon for TTS conversion.")
 
 
 
 
 
 
 
 
 
 
 
50
 
51
  # Step 6: Launch the app
52
  iface.launch(share=True)
 
1
+ # Step 1: Install Gradio
2
+ !pip install gradio
3
+
4
+ # Step 2: Import necessary libraries
5
  import gradio as gr
6
  import json
7
  import torch
 
15
  vocoder = SpeechT5HifiGan.from_pretrained("microsoft/speecht5_hifigan")
16
 
17
  # Load pronunciation dictionary from JSON file
18
+ with open("/content/pronunciation_dict.json", "r") as f:
19
  pronunciation_dict = json.load(f)
20
 
21
  # Function to preprocess the input text
 
45
 
46
  return output_file
47
 
48
+ # Step 5: Create Gradio interface with examples
49
+ examples = [
50
+ "We are using APIs and OAuth for authentication.",
51
+ "CUDA and TensorFlow work together for deep learning models.",
52
+ "The database uses NoSQL and supports JSON for data storage.",
53
+ "Machine learning and artificial intelligence are advancing fast.",
54
+ "Natural language processing techniques like GPT are widely adopted."
55
+ ]
56
+
57
+ iface = gr.Interface(
58
+ fn=text_to_speech,
59
+ inputs="text",
60
+ outputs="audio",
61
+ title="Text-to-Speech (TTS) Application",
62
+ description="Enter text with technical jargon for TTS conversion.",
63
+ examples=examples # Adding preset examples for users
64
+ )
65
 
66
  # Step 6: Launch the app
67
  iface.launch(share=True)