File size: 2,086 Bytes
b83b036
 
9b96eea
 
 
b83b036
9b96eea
 
b83b036
9b96eea
 
 
 
 
 
 
 
 
 
 
 
 
 
f9522cc
 
dd756db
534edcc
dd756db
b83b036
 
 
 
 
f4e9ad2
b83b036
174a693
 
b83b036
 
f4e9ad2
 
 
174a693
 
f4e9ad2
 
b83b036
 
 
 
 
 
9b96eea
f4e9ad2
b83b036
 
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import gradio as gr
from TTS.api import TTS
from bark import SAMPLE_RATE, generate_audio, preload_models
from scipy.io.wavfile import write as write_wav
from IPython.display import Audio

# download and load all models
preload_models()

def bark_try():
    # generate audio from text
    text_prompt = """
         Hello, my name is Suno. And, uh — and I like pizza. [laughs] 
         But I also have other interests such as playing tic tac toe.
    """
    audio_array = generate_audio(text_prompt)
    
    # save audio to disk
    write_wav("bark_generation.wav", SAMPLE_RATE, audio_array)
  
    # play text in notebook
    #Audio(audio_array, rate=SAMPLE_RATE)
    return ("bark_generation.wav")
def try1():
    model_name1 = TTS.list_models()
    print (f"model1 Name: {model_name1}")
    model_name = model_name1[0]
    print (f"model2 Name: {model_name}")
    # Init TTS
    tts = TTS(model_name)
    # Run TTS
    # ❗ Since this model is multi-speaker and multi-lingual, we must set the target speaker and the language
    # Text to speech with a numpy output
    #wav = tts.tts("This is a test! This is also a test!!", speaker=tts.speakers[0], language=tts.languages[0])
    # Text to speech to a file
    tts.tts_to_file(text="Hello world!", speaker=tts.speakers[0], language=tts.languages[0], file_path="./output.wav")
    out = "./output.wav"
    return out

#def try2():
    #tts = TTS(model_name="tts_models/multilingual/multi-dataset/your_tts", progress_bar=False, gpu=False)
    #tts.tts_to_file("This is voice cloning.", speaker_wav="my/cloning/audio.wav", language="en", file_path="output.wav")
    #tts.tts_to_file("C'est le clonage de la voix.", speaker_wav="my/cloning/audio.wav", language="fr", file_path="output.wav")
    #tts.tts_to_file("Isso é clonagem de voz.", speaker_wav="my/cloning/audio.wav", language="pt", file_path="output.wav")
    #out = "output.wav"
    #return out

with gr.Blocks() as app:
    out1 = gr.Audio()
    btn1 = gr.Button()
    btn2 = gr.Button()

    btn1.click(bark_try,None,out1)
    #btn2.click(try2,None,out1)

app.launch()