Spaces:
Sleeping
Sleeping
gospacedev
commited on
Commit
•
86b5bcb
1
Parent(s):
874fe80
remove user prompt
Browse files
app.py
CHANGED
@@ -28,7 +28,7 @@ pipe = pipeline(
|
|
28 |
)
|
29 |
|
30 |
|
31 |
-
def generate(
|
32 |
temperature = float(temperature)
|
33 |
if temperature < 1e-2:
|
34 |
temperature = 1e-2
|
@@ -43,8 +43,6 @@ def generate(user_prompt, instruct_history, temperature=0.1, max_new_tokens=128,
|
|
43 |
seed=42,
|
44 |
)
|
45 |
|
46 |
-
instruct_history += f"""<s>[INST] {user_prompt} [/INST] """
|
47 |
-
|
48 |
output = client.text_generation(
|
49 |
instruct_history, **generate_kwargs, stream=False, details=False, return_full_text=False)
|
50 |
|
@@ -57,11 +55,13 @@ def transcribe(audio, instruct_history=instruct_history, formatted_history=forma
|
|
57 |
y = y.astype(np.float32)
|
58 |
y /= np.max(np.abs(y))
|
59 |
|
60 |
-
|
|
|
|
|
61 |
|
62 |
-
|
63 |
|
64 |
-
llm_response = generate(
|
65 |
|
66 |
instruct_history += f""" {llm_response}</s>"""
|
67 |
|
@@ -89,7 +89,7 @@ with gr.Blocks() as demo:
|
|
89 |
|
90 |
transcription_box = gr.Textbox(label="Transcription")
|
91 |
|
92 |
-
transcribe_btn.click(fn=transcribe,
|
93 |
outputs=[output_audio, transcription_box])
|
94 |
|
95 |
if __name__ == "__main__":
|
|
|
28 |
)
|
29 |
|
30 |
|
31 |
+
def generate(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
|
|
|
43 |
seed=42,
|
44 |
)
|
45 |
|
|
|
|
|
46 |
output = client.text_generation(
|
47 |
instruct_history, **generate_kwargs, stream=False, details=False, return_full_text=False)
|
48 |
|
|
|
55 |
y = y.astype(np.float32)
|
56 |
y /= np.max(np.abs(y))
|
57 |
|
58 |
+
transcribed_user_audio = pipe({"sampling_rate": sr, "raw": y})["text"]
|
59 |
+
|
60 |
+
formatted_history += f"""Human: {transcribed_user_audio}\n\n"""
|
61 |
|
62 |
+
instruct_history += f"""<s>[INST] {transcribed_user_audio} [/INST] """
|
63 |
|
64 |
+
llm_response = generate(instruct_history)
|
65 |
|
66 |
instruct_history += f""" {llm_response}</s>"""
|
67 |
|
|
|
89 |
|
90 |
transcription_box = gr.Textbox(label="Transcription")
|
91 |
|
92 |
+
transcribe_btn.click(fn=transcribe, transcribed_user_audio=[audio_input],
|
93 |
outputs=[output_audio, transcription_box])
|
94 |
|
95 |
if __name__ == "__main__":
|