Spaces:
Sleeping
Sleeping
accent detection
Browse files
app.py
CHANGED
|
@@ -15,8 +15,11 @@ classifier = foreign_class(source="Jzuluaga/accent-id-commonaccent_xlsr-en-engli
|
|
| 15 |
|
| 16 |
# Placeholder accent classifier (replace with real one or your own logic)
|
| 17 |
def classify_accent(audio_tensor, sample_rate):
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
return {
|
| 22 |
"accent": "American",
|
|
|
|
| 15 |
|
| 16 |
# Placeholder accent classifier (replace with real one or your own logic)
|
| 17 |
def classify_accent(audio_tensor, sample_rate):
|
| 18 |
+
if sample_rate != 16000:
|
| 19 |
+
resampler = torchaudio.transforms.Resample(orig_freq=sample_rate, new_freq=16000)
|
| 20 |
+
audio_tensor = resampler(audio_tensor)
|
| 21 |
+
|
| 22 |
+
out_prob, score, index, text_lab = classifier.classify_batch(audio_tensor)
|
| 23 |
|
| 24 |
return {
|
| 25 |
"accent": "American",
|