Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -66,6 +66,7 @@ def inference(audio, prompt, model, temperature, latest):
|
|
| 66 |
infers = []
|
| 67 |
temp = []
|
| 68 |
#infered=[]
|
|
|
|
| 69 |
for i in range(5):
|
| 70 |
print("print1 ", response['choices'][i]['text'])
|
| 71 |
temp.append(response['choices'][i]['text'])
|
|
@@ -76,14 +77,26 @@ def inference(audio, prompt, model, temperature, latest):
|
|
| 76 |
#print("Infered type is: ", type(infered))
|
| 77 |
infers = list(map(lambda x: x.replace("\n", ""), temp))
|
| 78 |
#infered = list(map(lambda x: x.split(','), infers))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
print("INFERS TYPE: ", type(infers))
|
| 80 |
|
| 81 |
convoState = latest
|
| 82 |
-
infersStr = str(infers)
|
| 83 |
|
| 84 |
|
| 85 |
-
return transcript,
|
| 86 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
# get audio from microphone
|
| 88 |
with gr.Blocks() as face:
|
| 89 |
|
|
@@ -97,7 +110,12 @@ with gr.Blocks() as face:
|
|
| 97 |
transcribe_btn = gr.Button(value="Transcribe")
|
| 98 |
with gr.Column():
|
| 99 |
script = gr.Textbox(label="Transcribed text")
|
| 100 |
-
options = gr.Textbox(label="Predictions")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
#options = gr.Dataset(components=[gr.Radio], samples=["One", "Two", "Three", "Four", "Five"])
|
| 102 |
'''options = gr.Dataset(components=[gr.Textbox(visible=False)],
|
| 103 |
label="Text Dataset",
|
|
@@ -112,7 +130,7 @@ with gr.Blocks() as face:
|
|
| 112 |
#options = gr.Radio(choices=["One", "Two", "Three", "Four", "Five"])
|
| 113 |
latestConvo = gr.Textbox(label="Running conversation")
|
| 114 |
#transcribe_btn.click(inference)
|
| 115 |
-
transcribe_btn.click(fn=inference, inputs=[audio, promptText, dropChoice, sliderChoice, convoState], outputs=[script,
|
| 116 |
#examples = gr.Examples(examples=["Sedan, Truck, SUV", "Dalmaion, Shepherd, Lab, Mutt"], inputs=[options])
|
| 117 |
|
| 118 |
|
|
|
|
| 66 |
infers = []
|
| 67 |
temp = []
|
| 68 |
#infered=[]
|
| 69 |
+
|
| 70 |
for i in range(5):
|
| 71 |
print("print1 ", response['choices'][i]['text'])
|
| 72 |
temp.append(response['choices'][i]['text'])
|
|
|
|
| 77 |
#print("Infered type is: ", type(infered))
|
| 78 |
infers = list(map(lambda x: x.replace("\n", ""), temp))
|
| 79 |
#infered = list(map(lambda x: x.split(','), infers))
|
| 80 |
+
|
| 81 |
+
op1 = infers[0]
|
| 82 |
+
op2 = infers[1]
|
| 83 |
+
op3 = infers[2]
|
| 84 |
+
op4 = infers[3]
|
| 85 |
+
op5 = infers[4]
|
| 86 |
+
|
| 87 |
+
|
| 88 |
print("INFERS TYPE: ", type(infers))
|
| 89 |
|
| 90 |
convoState = latest
|
| 91 |
+
#infersStr = str(infers)
|
| 92 |
|
| 93 |
|
| 94 |
+
return transcript, op1, op2, op3, op4, op5, convoState
|
| 95 |
+
|
| 96 |
+
def appendPrediction(val, convoState):
|
| 97 |
+
convoState.append(val)
|
| 98 |
+
return convoState
|
| 99 |
+
|
| 100 |
# get audio from microphone
|
| 101 |
with gr.Blocks() as face:
|
| 102 |
|
|
|
|
| 110 |
transcribe_btn = gr.Button(value="Transcribe")
|
| 111 |
with gr.Column():
|
| 112 |
script = gr.Textbox(label="Transcribed text")
|
| 113 |
+
#options = gr.Textbox(label="Predictions")
|
| 114 |
+
option1 = gr.Button(value=" ")
|
| 115 |
+
option2 = gr.Button(value=" ")
|
| 116 |
+
option3 = gr.Button(value=" ")
|
| 117 |
+
option4 = gr.Button(value=" ")
|
| 118 |
+
option5 = gr.Button(value=" ")
|
| 119 |
#options = gr.Dataset(components=[gr.Radio], samples=["One", "Two", "Three", "Four", "Five"])
|
| 120 |
'''options = gr.Dataset(components=[gr.Textbox(visible=False)],
|
| 121 |
label="Text Dataset",
|
|
|
|
| 130 |
#options = gr.Radio(choices=["One", "Two", "Three", "Four", "Five"])
|
| 131 |
latestConvo = gr.Textbox(label="Running conversation")
|
| 132 |
#transcribe_btn.click(inference)
|
| 133 |
+
transcribe_btn.click(fn=inference, inputs=[audio, promptText, dropChoice, sliderChoice, convoState], outputs=[script, option1, option2, option3, option4, option5, latestConvo])
|
| 134 |
#examples = gr.Examples(examples=["Sedan, Truck, SUV", "Dalmaion, Shepherd, Lab, Mutt"], inputs=[options])
|
| 135 |
|
| 136 |
|