Spaces:
Sleeping
Sleeping
Commit
·
874fe80
1
Parent(s):
98bbe93
update transcribe inputs
Browse files
app.py
CHANGED
|
@@ -28,9 +28,7 @@ pipe = pipeline(
|
|
| 28 |
)
|
| 29 |
|
| 30 |
|
| 31 |
-
def generate(user_prompt, temperature=0.1, max_new_tokens=128, top_p=0.95, repetition_penalty=1.0):
|
| 32 |
-
global instruct_history
|
| 33 |
-
|
| 34 |
temperature = float(temperature)
|
| 35 |
if temperature < 1e-2:
|
| 36 |
temperature = 1e-2
|
|
@@ -54,21 +52,20 @@ def generate(user_prompt, temperature=0.1, max_new_tokens=128, top_p=0.95, repet
|
|
| 54 |
|
| 55 |
|
| 56 |
@spaces.GPU(duration=60)
|
| 57 |
-
def transcribe(audio):
|
| 58 |
-
global instruct_history, formatted_history
|
| 59 |
sr, y = audio
|
| 60 |
y = y.astype(np.float32)
|
| 61 |
y /= np.max(np.abs(y))
|
| 62 |
|
| 63 |
inputs = pipe({"sampling_rate": sr, "raw": y})["text"]
|
| 64 |
|
| 65 |
-
formatted_history += f"""Human: {inputs}\n"""
|
| 66 |
|
| 67 |
-
llm_response = generate(inputs)
|
| 68 |
|
| 69 |
instruct_history += f""" {llm_response}</s>"""
|
| 70 |
|
| 71 |
-
formatted_history += f"""Friday: {llm_response}\n"""
|
| 72 |
|
| 73 |
audio_response = gTTS(llm_response)
|
| 74 |
audio_response.save("response.mp3")
|
|
|
|
| 28 |
)
|
| 29 |
|
| 30 |
|
| 31 |
+
def generate(user_prompt, instruct_history, temperature=0.1, max_new_tokens=128, top_p=0.95, repetition_penalty=1.0):
|
|
|
|
|
|
|
| 32 |
temperature = float(temperature)
|
| 33 |
if temperature < 1e-2:
|
| 34 |
temperature = 1e-2
|
|
|
|
| 52 |
|
| 53 |
|
| 54 |
@spaces.GPU(duration=60)
|
| 55 |
+
def transcribe(audio, instruct_history=instruct_history, formatted_history=formatted_history):
|
|
|
|
| 56 |
sr, y = audio
|
| 57 |
y = y.astype(np.float32)
|
| 58 |
y /= np.max(np.abs(y))
|
| 59 |
|
| 60 |
inputs = pipe({"sampling_rate": sr, "raw": y})["text"]
|
| 61 |
|
| 62 |
+
formatted_history += f"""Human: {inputs}\n\n"""
|
| 63 |
|
| 64 |
+
llm_response = generate(inputs, instruct_history)
|
| 65 |
|
| 66 |
instruct_history += f""" {llm_response}</s>"""
|
| 67 |
|
| 68 |
+
formatted_history += f"""Friday: {llm_response}\n\n"""
|
| 69 |
|
| 70 |
audio_response = gTTS(llm_response)
|
| 71 |
audio_response.save("response.mp3")
|