Spaces:
Running
Running
Add resampling
Browse files- app.py +4 -1
- requirements.txt +1 -0
app.py
CHANGED
@@ -8,6 +8,7 @@ from transformers.models.wav2vec2.modeling_wav2vec2 import Wav2Vec2Model
|
|
8 |
from transformers.models.wav2vec2.modeling_wav2vec2 import Wav2Vec2PreTrainedModel
|
9 |
|
10 |
import audiofile
|
|
|
11 |
|
12 |
|
13 |
model_name = "audeering/wav2vec2-large-robust-24-ft-age-gender"
|
@@ -109,7 +110,9 @@ def recognize(file):
|
|
109 |
"before submitting your request."
|
110 |
)
|
111 |
signal, sampling_rate = audiofile.read(file, duration=duration)
|
112 |
-
|
|
|
|
|
113 |
age = f"{round(age_gender['age'])} years"
|
114 |
gender = {k: v for k, v in age_gender.items() if k != "age"}
|
115 |
return age, gender
|
|
|
8 |
from transformers.models.wav2vec2.modeling_wav2vec2 import Wav2Vec2PreTrainedModel
|
9 |
|
10 |
import audiofile
|
11 |
+
import audresample
|
12 |
|
13 |
|
14 |
model_name = "audeering/wav2vec2-large-robust-24-ft-age-gender"
|
|
|
110 |
"before submitting your request."
|
111 |
)
|
112 |
signal, sampling_rate = audiofile.read(file, duration=duration)
|
113 |
+
target_rate = 16000
|
114 |
+
signal = audresample.resample(signal, sampling_rate, target_rate)
|
115 |
+
age_gender = process_func(signal, target_rate)
|
116 |
age = f"{round(age_gender['age'])} years"
|
117 |
gender = {k: v for k, v in age_gender.items() if k != "age"}
|
118 |
return age, gender
|
requirements.txt
CHANGED
@@ -1,3 +1,4 @@
|
|
1 |
audiofile
|
|
|
2 |
torch
|
3 |
transformers
|
|
|
1 |
audiofile
|
2 |
+
audresample
|
3 |
torch
|
4 |
transformers
|