Spaces:
Sleeping
Sleeping
import re | |
from gender_prediction import get_gender | |
import gradio as gr | |
def app(voice): | |
model_name_or_path = "alefiury/wav2vec2-large-xlsr-53-gender-recognition-librispeech" | |
audio_paths = [voice] | |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu") | |
predicted_label = get_gender(model_name_or_path, audio_paths, device) | |
gender=re.search("female|male",predicted_label) | |
return gender.string | |
interface=gr.Interface(fn=app,inputs=[gr.components.Audio(type="filepath",sources="upload",label="upload voice")], | |
outputs=[gr.components.Textbox(label="your result")]) | |
interface.launch(debug=True) |