Update app.py
Browse files
app.py
CHANGED
|
@@ -45,24 +45,29 @@ def transcribe(audio, history_type):
|
|
| 45 |
role = f.read()
|
| 46 |
messages = [{"role": "system", "content": role}]
|
| 47 |
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
samplerate =
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
|
| 67 |
|
| 68 |
########## Cast as float 32, normalize
|
|
|
|
| 45 |
role = f.read()
|
| 46 |
messages = [{"role": "system", "content": role}]
|
| 47 |
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
######################## Take Audio from Numpy Array
|
| 52 |
+
samplerate, audio_data = audio
|
| 53 |
+
######################## Read audio file, if using file
|
| 54 |
+
#max_attempts = 1
|
| 55 |
+
#attempt = 0
|
| 56 |
+
#audio_data = None
|
| 57 |
+
#samplerate = None
|
| 58 |
+
#while attempt < max_attempts:
|
| 59 |
+
# try:
|
| 60 |
+
# if audio is None:
|
| 61 |
+
# raise TypeError("Invalid file: None")
|
| 62 |
+
# audio_data, samplerate = sf.read(audio)
|
| 63 |
+
# break
|
| 64 |
+
# except (OSError, TypeError) as e:
|
| 65 |
+
# print(f"Attempt {attempt + 1} of {max_attempts} failed with error: {e}")
|
| 66 |
+
# attempt += 1
|
| 67 |
+
# time.sleep(3)
|
| 68 |
+
#else:
|
| 69 |
+
# print(f"###############Failed to open audio file after {max_attempts} attempts.##############")
|
| 70 |
+
# return # Terminate the function or raise an exception if the file could not be opened
|
| 71 |
|
| 72 |
|
| 73 |
########## Cast as float 32, normalize
|