Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -146,6 +146,37 @@ def auto_reset_state():
|
|
146 |
time.sleep(5)
|
147 |
return None, ""
|
148 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
def transcribe_function(stream, new_chunk):
|
150 |
try:
|
151 |
sr, y = new_chunk[0], new_chunk[1]
|
@@ -548,8 +579,8 @@ def response(audio: tuple[int, np.ndarray], conversation_llm_format: list[dict],
|
|
548 |
|
549 |
#prompt = "Hey Annie how are you"
|
550 |
#prompt = transcribe_function (client_state.grState, audio)
|
551 |
-
|
552 |
-
prompt = client_state.hf.automatic_speech_recognition(audio_to_bytes(audio),model="https://u3fcydn2o5vvwyd0.us-east-1.aws.endpoints.huggingface.cloud").text
|
553 |
|
554 |
# ADDED BY AL TO USE THE SPEECH TO TEXT GRADIO CLIENT - not working
|
555 |
# # client = Client("on1onmangoes/radarheyanniebackend112724")
|
|
|
146 |
time.sleep(5)
|
147 |
return None, ""
|
148 |
|
149 |
+
|
150 |
+
def transcribe(
|
151 |
+
audio: tuple[int, np.ndarray],
|
152 |
+
transformers_chat: list[dict],
|
153 |
+
conversation: list[dict],
|
154 |
+
):
|
155 |
+
original_sr = audio[0]
|
156 |
+
target_sr = 16000
|
157 |
+
|
158 |
+
audio_sr = librosa.resample(
|
159 |
+
audio[1].astype(np.float32) / 32768.0, orig_sr=original_sr, target_sr=target_sr
|
160 |
+
)
|
161 |
+
|
162 |
+
tf_input = [d for d in transformers_chat]
|
163 |
+
|
164 |
+
output = pipe(
|
165 |
+
{"audio": audio_sr, "turns": tf_input, "sampling_rate": target_sr},
|
166 |
+
max_new_tokens=512,
|
167 |
+
)
|
168 |
+
transcription = whisper({"array": audio_sr.squeeze(), "sampling_rate": target_sr})
|
169 |
+
yield AdditionalOutputs
|
170 |
+
|
171 |
+
# conversation.append({"role": "user", "content": transcription["text"]})
|
172 |
+
# conversation.append({"role": "assistant", "content": output})
|
173 |
+
# transformers_chat.append({"role": "user", "content": transcription["text"]})
|
174 |
+
# transformers_chat.append({"role": "assistant", "content": output})
|
175 |
+
|
176 |
+
# yield AdditionalOutputs(transformers_chat, conversation)
|
177 |
+
|
178 |
+
|
179 |
+
|
180 |
def transcribe_function(stream, new_chunk):
|
181 |
try:
|
182 |
sr, y = new_chunk[0], new_chunk[1]
|
|
|
579 |
|
580 |
#prompt = "Hey Annie how are you"
|
581 |
#prompt = transcribe_function (client_state.grState, audio)
|
582 |
+
prompt = client_state.hf.automatic_speech_recognition(audio_to_bytes(audio),model="https://kttcvz41e0htmjpp.us-east-1.aws.endpoints.huggingface.cloud").text
|
583 |
+
#prompt = client_state.hf.automatic_speech_recognition(audio_to_bytes(audio),model="https://u3fcydn2o5vvwyd0.us-east-1.aws.endpoints.huggingface.cloud").text
|
584 |
|
585 |
# ADDED BY AL TO USE THE SPEECH TO TEXT GRADIO CLIENT - not working
|
586 |
# # client = Client("on1onmangoes/radarheyanniebackend112724")
|