Spaces:
				
			
			
	
			
			
		Runtime error
		
	
	
	
			
			
	
	
	
	
		
		
		Runtime error
		
	Create app.py
Browse files
    	
        app.py
    ADDED
    
    | @@ -0,0 +1,31 @@ | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | 
|  | |
| 1 | 
            +
            import spaces
         | 
| 2 | 
            +
            import gradio as gr
         | 
| 3 | 
            +
            import torch
         | 
| 4 | 
            +
            from TTS.api import TTS
         | 
| 5 | 
            +
            import os
         | 
| 6 | 
            +
            os.environ["COQUI_TOS_AGREED"] = "1"
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            device = "cuda"
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2").to(device)
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            @spaces.GPU(enable_queue=True)
         | 
| 13 | 
            +
            def clone(text, audio):
         | 
| 14 | 
            +
                tts.tts_to_file(text=text, speaker_wav=audio, language="en", file_path="./output.wav")
         | 
| 15 | 
            +
                return "./output.wav"
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            iface = gr.Interface(fn=clone, 
         | 
| 18 | 
            +
                                 inputs=[gr.Textbox(label='Text'),gr.Audio(type='filepath', label='Voice reference audio file')], 
         | 
| 19 | 
            +
                                 outputs=gr.Audio(type='filepath'),
         | 
| 20 | 
            +
                                 title='Voicy',
         | 
| 21 | 
            +
                                 description="""
         | 
| 22 | 
            +
                                 This space uses xtts_v2 model. Non-commercial use only. [Coqui Public Model License](https://coqui.ai/cpml)
         | 
| 23 | 
            +
                                                      """,
         | 
| 24 | 
            +
                                 theme = gr.themes.Base(primary_hue="teal",secondary_hue="teal",neutral_hue="slate"),
         | 
| 25 | 
            +
                                 examples=[["Hey! It's me Dorthy, from the Wizard of Oz. Type in whatever you'd like me to say.","./audio/Wizard-of-Oz-Dorthy.wav"],
         | 
| 26 | 
            +
                                           ["It's me Vito Corleone, from the Godfather. Type in whatever you'd like me to say.","./audio/Godfather.wav"],
         | 
| 27 | 
            +
                                           ["Hey, it's me Paris Hilton. Type in whatever you'd like me to say.","./audio/Paris-Hilton.mp3"],
         | 
| 28 | 
            +
                                           ["Hey, it's me Megan Fox from Transformers. Type in whatever you'd like me to say.","./audio/Megan-Fox.mp3"],
         | 
| 29 | 
            +
                                           ["Hey there, it's me Jeff Goldblum. Type in whatever you'd like me to say.","./audio/Jeff-Goldblum.mp3"],
         | 
| 30 | 
            +
                                           ["Hey there, it's me Heath Ledger as the Joker. Type in whatever you'd like me to say.","./audio/Heath-Ledger.mp3"],])
         | 
| 31 | 
            +
            iface.launch()
         | 
