Update app.py
Browse files
app.py
CHANGED
|
@@ -1,15 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from transformers import pipeline
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
speech = pipeline("text-to-speech", model="microsoft/speecht5_tts")
|
| 6 |
def summarize_text_and_speak(prompt):
|
| 7 |
summary = summarizer(prompt, max_length=150, min_length=30, do_sample=False)
|
| 8 |
summary_text = summary[0]['summary_text']
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
| 10 |
return summary_text, audio["audio"]
|
| 11 |
-
|
| 12 |
-
|
| 13 |
interface = gr.Interface(
|
| 14 |
fn=summarize_text_and_speak,
|
| 15 |
inputs=gr.Textbox(lines=10, label="Input text"),
|
|
|
|
| 1 |
+
from transformers import SpeechT5Processor, SpeechT5ForTextToSpeech, SpeechT5HifiGan
|
| 2 |
+
from datasets import load_dataset
|
| 3 |
+
import torch
|
| 4 |
+
import soundfile as sf
|
| 5 |
+
from datasets import load_dataset
|
| 6 |
from transformers import pipeline
|
| 7 |
import gradio as gr
|
| 8 |
|
| 9 |
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
|
| 10 |
+
# code from the Model card
|
| 11 |
+
processor = SpeechT5Processor.from_pretrained("microsoft/speecht5_tts")
|
| 12 |
+
model = SpeechT5ForTextToSpeech.from_pretrained("microsoft/speecht5_tts")
|
| 13 |
+
vocoder = SpeechT5HifiGan.from_pretrained("microsoft/speecht5_hifigan")
|
| 14 |
+
|
| 15 |
+
|
| 16 |
speech = pipeline("text-to-speech", model="microsoft/speecht5_tts")
|
| 17 |
def summarize_text_and_speak(prompt):
|
| 18 |
summary = summarizer(prompt, max_length=150, min_length=30, do_sample=False)
|
| 19 |
summary_text = summary[0]['summary_text']
|
| 20 |
+
#inputs = processor(text="Hello, my dog is cute.", return_tensors="pt")
|
| 21 |
+
inputs = processor(text=summary_text, return_tensors="pt")
|
| 22 |
+
#speech = model.generate_speech(inputs["input_ids"], speaker_embeddings, vocoder=vocoder)
|
| 23 |
+
speech = model.generate_speech(inputs["input_ids"], speaker_embeddings, vocoder=vocoder)
|
| 24 |
return summary_text, audio["audio"]
|
| 25 |
+
|
|
|
|
| 26 |
interface = gr.Interface(
|
| 27 |
fn=summarize_text_and_speak,
|
| 28 |
inputs=gr.Textbox(lines=10, label="Input text"),
|