Spaces:
Runtime error
Runtime error
Commit
·
cd2a3be
1
Parent(s):
5dcf83f
update file treatment
Browse files
app.py
CHANGED
|
@@ -82,6 +82,8 @@ from transformers import pipeline
|
|
| 82 |
import soundfile as sf
|
| 83 |
from scipy.io import wavfile
|
| 84 |
|
|
|
|
|
|
|
| 85 |
ds = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
|
| 86 |
sample = ds[0]["audio"]
|
| 87 |
|
|
@@ -1105,8 +1107,8 @@ def chathmi3(message, history2):
|
|
| 1105 |
# real_content = response[-1:]
|
| 1106 |
# print("real_content", real_content)
|
| 1107 |
try:
|
| 1108 |
-
temp = response.split("(sandbox:/")[1] # (sandbox:/sample-20230805-0807.wav)
|
| 1109 |
-
file_name =
|
| 1110 |
print("file_name:", file_name)
|
| 1111 |
history2 = history2 + [(None, (file_name,))]
|
| 1112 |
Filename_Chatbot = file_name
|
|
@@ -1123,6 +1125,14 @@ def chathmi3(message, history2):
|
|
| 1123 |
print("-" * 20)
|
| 1124 |
print("-" * 20)
|
| 1125 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1126 |
def chathmi4(message, history2):
|
| 1127 |
global last_request
|
| 1128 |
global Filename_Chatbot
|
|
@@ -1147,8 +1157,8 @@ def chathmi4(message, history2):
|
|
| 1147 |
# real_content = response[-1:]
|
| 1148 |
# print("real_content", real_content)
|
| 1149 |
try:
|
| 1150 |
-
temp = response.split("(sandbox:/")[1] # (sandbox:/sample-20230805-0807.wav)
|
| 1151 |
-
file_name =
|
| 1152 |
print("file_name:", file_name)
|
| 1153 |
history2 = history2 + [(None, (file_name,))]
|
| 1154 |
Filename_Chatbot = file_name
|
|
|
|
| 82 |
import soundfile as sf
|
| 83 |
from scipy.io import wavfile
|
| 84 |
|
| 85 |
+
import re
|
| 86 |
+
|
| 87 |
ds = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
|
| 88 |
sample = ds[0]["audio"]
|
| 89 |
|
|
|
|
| 1107 |
# real_content = response[-1:]
|
| 1108 |
# print("real_content", real_content)
|
| 1109 |
try:
|
| 1110 |
+
# temp = response.split("(sandbox:/")[1] # (sandbox:/sample-20230805-0807.wav)
|
| 1111 |
+
file_name = CheckFileinResp(response)
|
| 1112 |
print("file_name:", file_name)
|
| 1113 |
history2 = history2 + [(None, (file_name,))]
|
| 1114 |
Filename_Chatbot = file_name
|
|
|
|
| 1125 |
print("-" * 20)
|
| 1126 |
print("-" * 20)
|
| 1127 |
|
| 1128 |
+
def CheckFileinResp(response):
|
| 1129 |
+
try:
|
| 1130 |
+
pattern = r'sample-\w+\.wav'
|
| 1131 |
+
result = re.findall(pattern, response)
|
| 1132 |
+
return result[-1]
|
| 1133 |
+
except Exception as e:
|
| 1134 |
+
print("No wav found:", e)
|
| 1135 |
+
|
| 1136 |
def chathmi4(message, history2):
|
| 1137 |
global last_request
|
| 1138 |
global Filename_Chatbot
|
|
|
|
| 1157 |
# real_content = response[-1:]
|
| 1158 |
# print("real_content", real_content)
|
| 1159 |
try:
|
| 1160 |
+
# temp = response.split("(sandbox:/")[1] # (sandbox:/sample-20230805-0807.wav)
|
| 1161 |
+
file_name = CheckFileinResp(response)
|
| 1162 |
print("file_name:", file_name)
|
| 1163 |
history2 = history2 + [(None, (file_name,))]
|
| 1164 |
Filename_Chatbot = file_name
|