Spaces:
				
			
			
	
			
			
		Running
		
			on 
			
			Zero
	
	
	
			
			
	
	
	
	
		
		
		Running
		
			on 
			
			Zero
	Update app.py
Browse files
    	
        app.py
    CHANGED
    
    | @@ -18,6 +18,9 @@ from typing import Union | |
| 18 | 
             
            from diffusers.utils.torch_utils import randn_tensor
         | 
| 19 | 
             
            from tqdm import tqdm
         | 
| 20 |  | 
|  | |
|  | |
|  | |
| 21 | 
             
            class Tango2Pipeline(DiffusionPipeline):
         | 
| 22 | 
             
                def __init__(
         | 
| 23 | 
             
                    self,
         | 
| @@ -243,9 +246,14 @@ pipe = Tango2Pipeline(vae=tango.vae, | |
| 243 |  | 
| 244 | 
             
            @spaces.GPU(duration=60)
         | 
| 245 | 
             
            def gradio_generate(prompt, output_format, steps, guidance):
         | 
| 246 | 
            -
                 | 
| 247 | 
            -
                 | 
| 248 | 
            -
             | 
|  | |
|  | |
|  | |
|  | |
|  | |
| 249 | 
             
                output_wave = output_wave.audios[0]
         | 
| 250 | 
             
                output_filename = "temp.wav"
         | 
| 251 | 
             
                wavio.write(output_filename, output_wave, rate=16000, sampwidth=2)
         | 
| @@ -256,7 +264,6 @@ def gradio_generate(prompt, output_format, steps, guidance): | |
| 256 |  | 
| 257 | 
             
                return output_filename
         | 
| 258 |  | 
| 259 | 
            -
             | 
| 260 | 
             
            input_text = gr.Textbox(lines=2, label="Prompt")
         | 
| 261 | 
             
            output_format = gr.Radio(label = "Output format", info = "The file you can dowload", choices = ["mp3", "wav"], value = "wav")
         | 
| 262 | 
             
            output_audio = gr.Audio(label="Generated Audio", type="filepath")
         | 
|  | |
| 18 | 
             
            from diffusers.utils.torch_utils import randn_tensor
         | 
| 19 | 
             
            from tqdm import tqdm
         | 
| 20 |  | 
| 21 | 
            +
            from transformers import pipeline
         | 
| 22 | 
            +
            translator = pipeline("translation", model="Helsinki-NLP/opus-mt-ko-en")
         | 
| 23 | 
            +
             | 
| 24 | 
             
            class Tango2Pipeline(DiffusionPipeline):
         | 
| 25 | 
             
                def __init__(
         | 
| 26 | 
             
                    self,
         | 
|  | |
| 246 |  | 
| 247 | 
             
            @spaces.GPU(duration=60)
         | 
| 248 | 
             
            def gradio_generate(prompt, output_format, steps, guidance):
         | 
| 249 | 
            +
                # ํ๊ธ์ด ํฌํจ๋์ด ์๋์ง ํ์ธ
         | 
| 250 | 
            +
                if any(ord('๊ฐ') <= ord(char) <= ord('ํฃ') for char in prompt):
         | 
| 251 | 
            +
                    # ํ๊ธ์ ์์ด๋ก ๋ฒ์ญ
         | 
| 252 | 
            +
                    translation = translator(prompt)[0]['translation_text']
         | 
| 253 | 
            +
                    prompt = translation
         | 
| 254 | 
            +
                    print(f"Translated prompt: {prompt}")
         | 
| 255 | 
            +
                
         | 
| 256 | 
            +
                output_wave = pipe(prompt,steps,guidance)
         | 
| 257 | 
             
                output_wave = output_wave.audios[0]
         | 
| 258 | 
             
                output_filename = "temp.wav"
         | 
| 259 | 
             
                wavio.write(output_filename, output_wave, rate=16000, sampwidth=2)
         | 
|  | |
| 264 |  | 
| 265 | 
             
                return output_filename
         | 
| 266 |  | 
|  | |
| 267 | 
             
            input_text = gr.Textbox(lines=2, label="Prompt")
         | 
| 268 | 
             
            output_format = gr.Radio(label = "Output format", info = "The file you can dowload", choices = ["mp3", "wav"], value = "wav")
         | 
| 269 | 
             
            output_audio = gr.Audio(label="Generated Audio", type="filepath")
         | 
