File size: 738 Bytes
132646e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import gradio as gr
from transformers import pipeline

def process_files():
    return (gr.update(interactive=True,
                      elem_id='summary_button'),
    gr.update(interactive = True, elem_id = 'summarization_method')
    )



def get_summarization_method(option):
    return option




def text_to_audio(text, model_name="facebook/fastspeech2-en-ljspeech"):
    # Initialize the TTS pipeline
    tts_pipeline = pipeline("text-to-speech", model=model_name)
    
    # Generate the audio from text
    audio = tts_pipeline(text)
    
    # Save the audio to a file
    audio_path = "output.wav"
    with open(audio_path, "wb") as file:
        file.write(audio["wav"])
    
    return audio_path