Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -81,23 +81,6 @@ def add_note_to_history(note, note_history):
|
|
81 |
return [note_history]
|
82 |
|
83 |
|
84 |
-
def chat(message, history):
|
85 |
-
history = history or []
|
86 |
-
if history:
|
87 |
-
history_useful = ['</s> <s>'.join([str(a[0])+'</s> <s>'+str(a[1]) for a in history])]
|
88 |
-
else:
|
89 |
-
history_useful = []
|
90 |
-
history_useful = add_note_to_history(message, history_useful)
|
91 |
-
inputs = tokenizer(history_useful, return_tensors="pt")
|
92 |
-
inputs, history_useful, history = take_last_tokens(inputs, history_useful, history)
|
93 |
-
reply_ids = model.generate(**inputs)
|
94 |
-
response = tokenizer.batch_decode(reply_ids, skip_special_tokens=True)[0]
|
95 |
-
history_useful = add_note_to_history(response, history_useful)
|
96 |
-
list_history = history_useful[0].split('</s> <s>')
|
97 |
-
history.append((list_history[-2], list_history[-1]))
|
98 |
-
ret = store_message(message, response) # Save to dataset - uncomment if you uncomment above to save inputs and outputs to your dataset
|
99 |
-
return history, history, ret
|
100 |
-
|
101 |
|
102 |
SAMPLE_RATE = 16000
|
103 |
model = nemo_asr.models.EncDecRNNTBPEModel.from_pretrained("nvidia/stt_en_conformer_transducer_xlarge")
|
@@ -123,9 +106,9 @@ def transcribe(audio, state = ""):
|
|
123 |
if type(transcriptions) == tuple and len(transcriptions) == 2:
|
124 |
transcriptions = transcriptions[0]
|
125 |
transcriptions = transcriptions[0]
|
126 |
-
store_message(transcriptions, state) # Save to dataset - uncomment to store into a dataset - hint you will need your HF_TOKEN
|
127 |
state = state + transcriptions + " "
|
128 |
-
return state, state
|
129 |
|
130 |
gr.Interface(
|
131 |
fn=transcribe,
|
|
|
81 |
return [note_history]
|
82 |
|
83 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
|
85 |
SAMPLE_RATE = 16000
|
86 |
model = nemo_asr.models.EncDecRNNTBPEModel.from_pretrained("nvidia/stt_en_conformer_transducer_xlarge")
|
|
|
106 |
if type(transcriptions) == tuple and len(transcriptions) == 2:
|
107 |
transcriptions = transcriptions[0]
|
108 |
transcriptions = transcriptions[0]
|
109 |
+
ret = store_message(transcriptions, state) # Save to dataset - uncomment to store into a dataset - hint you will need your HF_TOKEN
|
110 |
state = state + transcriptions + " "
|
111 |
+
return state, state, ret
|
112 |
|
113 |
gr.Interface(
|
114 |
fn=transcribe,
|