Spaces:
Build error
Build error
fuck it, find out
Browse files
app.py
CHANGED
@@ -25,7 +25,9 @@ embedding_model = PretrainedSpeakerEmbedding(
|
|
25 |
)
|
26 |
|
27 |
def transcribe(audio, num_speakers):
|
28 |
-
path = convert_to_wav(audio)
|
|
|
|
|
29 |
|
30 |
duration = get_duration(path)
|
31 |
if duration > 4 * 60 * 60:
|
@@ -45,9 +47,16 @@ def transcribe(audio, num_speakers):
|
|
45 |
|
46 |
def convert_to_wav(path):
|
47 |
if path[-3:] != 'wav':
|
48 |
-
|
49 |
-
|
50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
|
52 |
def get_duration(path):
|
53 |
with contextlib.closing(wave.open(path,'r')) as f:
|
|
|
25 |
)
|
26 |
|
27 |
def transcribe(audio, num_speakers):
|
28 |
+
path, error = convert_to_wav(audio)
|
29 |
+
if error is not None:
|
30 |
+
return error
|
31 |
|
32 |
duration = get_duration(path)
|
33 |
if duration > 4 * 60 * 60:
|
|
|
47 |
|
48 |
def convert_to_wav(path):
|
49 |
if path[-3:] != 'wav':
|
50 |
+
new_path = '.'.join(path.split('.')[:-1]) + '.wav'
|
51 |
+
try:
|
52 |
+
subprocess.call(['ffmpeg', '-i', path, '-c', 'copy', new_path, '-y'])
|
53 |
+
except:
|
54 |
+
try:
|
55 |
+
subprocess.call(['ffmpeg', '-i', path, new_path, '-y'])
|
56 |
+
except:
|
57 |
+
return path, 'Error: Could not convert file to .wav'
|
58 |
+
path = new_path
|
59 |
+
return path, None
|
60 |
|
61 |
def get_duration(path):
|
62 |
with contextlib.closing(wave.open(path,'r')) as f:
|