File size: 1,112 Bytes
2c7b92a
 
 
 
 
ff2abf3
4806fb4
 
 
 
 
ff2abf3
4806fb4
15dcfdb
4806fb4
 
47adc7e
d753863
4806fb4
641c2f8
4806fb4
2c7b92a
 
47adc7e
2c7b92a
 
 
47adc7e
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
import gradio as gr
from inference import InferencePipeline

i = InferencePipeline()

def gradio_voice_conversion(audio_file_path):
    """
    Wrapper function to handle Gradio's audio input and pass the file path to the voice conversion function.
    Gradio passes audio data as a tuple: (temp file path, sample rate).
    """
    # Gradio passes audio as (temp file path, sample rate)
    #audio_file_path = audio_data[0]  # Extract the file path
    print(f"Here is the audio_file_path: {audio_file_path}")
    #print(f"Here is the audio_file_path[0]: {audio_file_path[0]}")
    return i.voice_conversion(audio_file_path)

# Define your Gradio interface
demo = gr.Interface(
    fn=gradio_voice_conversion,  # Use the wrapper function for voice conversion
    inputs=gr.Audio(label="Record or upload your voice", type="filepath"),  # Specify that you want the filepath
    outputs=gr.Audio(label="Converted Voice"),
    title="Voice Conversion Demo",
    description="Voice Conversion: Transform the input voice to a target voice.",
    allow_flagging="never"
)

if __name__ == "__main__":
    demo.launch()