File size: 639 Bytes
6ac6810
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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)