Spaces:
Sleeping
Sleeping
Salman11223
commited on
Commit
•
6ac6810
1
Parent(s):
7d66980
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import re
|
2 |
+
from gender_prediction import get_gender
|
3 |
+
import gradio as gr
|
4 |
+
|
5 |
+
def app(voice):
|
6 |
+
model_name_or_path = "alefiury/wav2vec2-large-xlsr-53-gender-recognition-librispeech"
|
7 |
+
audio_paths = [voice]
|
8 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
9 |
+
predicted_label = get_gender(model_name_or_path, audio_paths, device)
|
10 |
+
gender=re.search("female|male",predicted_label)
|
11 |
+
return gender.string
|
12 |
+
|
13 |
+
|
14 |
+
interface=gr.Interface(fn=app,inputs=[gr.components.Audio(type="filepath",sources="upload",label="upload voice")],
|
15 |
+
outputs=[gr.components.Textbox(label="your result")])
|
16 |
+
interface.launch(debug=True)
|