Spaces:
				
			
			
	
			
			
		Runtime error
		
	
	
	
			
			
	
	
	
	
		
		
		Runtime error
		
	Update app.py
Browse files
    	
        app.py
    CHANGED
    
    | @@ -43,10 +43,12 @@ def transcribe(audio_file): | |
| 43 | 
             
                transcription = asr_model.transcribe(audio_file)["text"]
         | 
| 44 | 
             
                return transcription
         | 
| 45 |  | 
| 46 | 
            -
            def inference(audio, prompt, model, temperature):
         | 
| 47 | 
             
                # Transcribe with Whisper
         | 
| 48 | 
             
                print("The audio is:", audio)
         | 
| 49 | 
             
                transcript = transcribe(audio)
         | 
|  | |
|  | |
| 50 |  | 
| 51 | 
             
                text = prompt + transcript + "\nPrediction: "
         | 
| 52 |  | 
| @@ -70,12 +72,14 @@ def inference(audio, prompt, model, temperature): | |
| 70 | 
             
                    #print("Infered type is: ", type(infered))
         | 
| 71 | 
             
                    infers = list(map(lambda x: x.replace("\n", ""), temp))
         | 
| 72 | 
             
                    #infered = list(map(lambda x: x.split(','), infers))
         | 
|  | |
| 73 |  | 
| 74 | 
            -
                return transcript, infers
         | 
| 75 |  | 
| 76 |  | 
| 77 | 
             
            # get audio from microphone 
         | 
| 78 | 
             
            with gr.Blocks() as face:
         | 
|  | |
| 79 | 
             
                with gr.Row():
         | 
| 80 | 
             
                    with gr.Column():
         | 
| 81 | 
             
                        audio = gr.Audio(source="microphone", type="filepath")
         | 
| @@ -86,8 +90,9 @@ with gr.Blocks() as face: | |
| 86 | 
             
                    with gr.Column():
         | 
| 87 | 
             
                        script = gr.Textbox(label="text...")
         | 
| 88 | 
             
                        options = gr.Textbox(label="predictions...")
         | 
|  | |
| 89 | 
             
                        #transcribe_btn.click(inference)
         | 
| 90 | 
            -
                transcribe_btn.click(fn=inference, inputs=[audio, promptText, dropChoice, sliderChoice], outputs=[script, options])
         | 
| 91 | 
             
                examples = gr.Examples(examples=["Sedan, Truck, SUV", "Dalmaion, Shepherd, Lab, Mutt"], inputs=[options])
         | 
| 92 |  | 
| 93 | 
             
            face.launch()
         | 
|  | |
| 43 | 
             
                transcription = asr_model.transcribe(audio_file)["text"]
         | 
| 44 | 
             
                return transcription
         | 
| 45 |  | 
| 46 | 
            +
            def inference(audio, prompt, model, temperature, latest):
         | 
| 47 | 
             
                # Transcribe with Whisper
         | 
| 48 | 
             
                print("The audio is:", audio)
         | 
| 49 | 
             
                transcript = transcribe(audio)
         | 
| 50 | 
            +
             | 
| 51 | 
            +
                lastest.append(transcript)
         | 
| 52 |  | 
| 53 | 
             
                text = prompt + transcript + "\nPrediction: "
         | 
| 54 |  | 
|  | |
| 72 | 
             
                    #print("Infered type is: ", type(infered))
         | 
| 73 | 
             
                    infers = list(map(lambda x: x.replace("\n", ""), temp))
         | 
| 74 | 
             
                    #infered = list(map(lambda x: x.split(','), infers))
         | 
| 75 | 
            +
                    convoState: latest
         | 
| 76 |  | 
| 77 | 
            +
                return transcript, infers, convoState
         | 
| 78 |  | 
| 79 |  | 
| 80 | 
             
            # get audio from microphone 
         | 
| 81 | 
             
            with gr.Blocks() as face:
         | 
| 82 | 
            +
                convoState = gr.State([])
         | 
| 83 | 
             
                with gr.Row():
         | 
| 84 | 
             
                    with gr.Column():
         | 
| 85 | 
             
                        audio = gr.Audio(source="microphone", type="filepath")
         | 
|  | |
| 90 | 
             
                    with gr.Column():
         | 
| 91 | 
             
                        script = gr.Textbox(label="text...")
         | 
| 92 | 
             
                        options = gr.Textbox(label="predictions...")
         | 
| 93 | 
            +
                        latestConvo = gr.Textbox()
         | 
| 94 | 
             
                        #transcribe_btn.click(inference)
         | 
| 95 | 
            +
                transcribe_btn.click(fn=inference, inputs=[audio, promptText, dropChoice, sliderChoice, convoState], outputs=[script, options, latestConvo])
         | 
| 96 | 
             
                examples = gr.Examples(examples=["Sedan, Truck, SUV", "Dalmaion, Shepherd, Lab, Mutt"], inputs=[options])
         | 
| 97 |  | 
| 98 | 
             
            face.launch()
         |