Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,7 +5,6 @@ import librosa
|
|
| 5 |
from pathlib import Path
|
| 6 |
import tempfile, torchaudio
|
| 7 |
from transformers import pipeline
|
| 8 |
-
from uuid import uuid4
|
| 9 |
|
| 10 |
# Load the MARS5 model
|
| 11 |
mars5, config_class = torch.hub.load('Camb-ai/mars5-tts', 'mars5_english', trust_repo=True)
|
|
@@ -24,16 +23,6 @@ def transcribe_file(f: str) -> str:
|
|
| 24 |
# Function to process the text and audio input and generate the synthesized output
|
| 25 |
def synthesize(text, audio_file, transcript, kwargs_dict):
|
| 26 |
print(f">>>>>>> Kwargs dict: {kwargs_dict}")
|
| 27 |
-
# audio_file = Path(audio_file)
|
| 28 |
-
# temp_file = f"{uuid4()}.{audio_file.suffix}"
|
| 29 |
-
|
| 30 |
-
# # copying the audio_file
|
| 31 |
-
# with open(audio_file, 'rb') as src, open(temp_file, 'wb') as dst:
|
| 32 |
-
# dst.write(src.read())
|
| 33 |
-
|
| 34 |
-
# audio_file = temp_file
|
| 35 |
-
|
| 36 |
-
print(f">>>>> synthesizing! audio_file: {audio_file}")
|
| 37 |
if not transcript:
|
| 38 |
transcript = transcribe_file(audio_file)
|
| 39 |
|
|
@@ -67,7 +56,9 @@ defaults = {
|
|
| 67 |
|
| 68 |
|
| 69 |
with gr.Blocks() as demo:
|
| 70 |
-
|
|
|
|
|
|
|
| 71 |
text = gr.Textbox(label="Text to synthesize")
|
| 72 |
audio_file = gr.Audio(label="Audio file to clone from", type="filepath")
|
| 73 |
|
|
@@ -143,8 +134,8 @@ with gr.Blocks() as demo:
|
|
| 143 |
# Add examples
|
| 144 |
defaults = [0.8, -1, 0.2, 1.0, 2.6, 0.4, 100, 3, True]
|
| 145 |
examples = [
|
| 146 |
-
["
|
| 147 |
-
["
|
| 148 |
]
|
| 149 |
|
| 150 |
gr.Examples(
|
|
|
|
| 5 |
from pathlib import Path
|
| 6 |
import tempfile, torchaudio
|
| 7 |
from transformers import pipeline
|
|
|
|
| 8 |
|
| 9 |
# Load the MARS5 model
|
| 10 |
mars5, config_class = torch.hub.load('Camb-ai/mars5-tts', 'mars5_english', trust_repo=True)
|
|
|
|
| 23 |
# Function to process the text and audio input and generate the synthesized output
|
| 24 |
def synthesize(text, audio_file, transcript, kwargs_dict):
|
| 25 |
print(f">>>>>>> Kwargs dict: {kwargs_dict}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
if not transcript:
|
| 27 |
transcript = transcribe_file(audio_file)
|
| 28 |
|
|
|
|
| 56 |
|
| 57 |
|
| 58 |
with gr.Blocks() as demo:
|
| 59 |
+
link = "https://github.com/Camb-ai/MARS5-TTS"
|
| 60 |
+
gr.Markdown("## MARS5 TTS Demo\nEnter text and upload an audio file to clone the voice and generate synthesized speech using **[MARS5-TTS]({link})**")
|
| 61 |
+
|
| 62 |
text = gr.Textbox(label="Text to synthesize")
|
| 63 |
audio_file = gr.Audio(label="Audio file to clone from", type="filepath")
|
| 64 |
|
|
|
|
| 134 |
# Add examples
|
| 135 |
defaults = [0.8, -1, 0.2, 1.0, 2.6, 0.4, 100, 3, True]
|
| 136 |
examples = [
|
| 137 |
+
["Can you please go there and figure it out?", "female_speaker_1.flac", "People look, but no one ever finds it.", *defaults],
|
| 138 |
+
["Hey, do you need my help?", "male_speaker_1.flac", "Ask her to bring these things with her from the store.", *defaults]
|
| 139 |
]
|
| 140 |
|
| 141 |
gr.Examples(
|