Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -35,7 +35,7 @@ def upsert(text):
|
|
| 35 |
date_time =str(datetime.datetime.today())
|
| 36 |
doc_ref = db.collection('Text2SpeechSentimentSave').document(date_time)
|
| 37 |
doc_ref.set({u'firefield': 'Recognize Speech', u'first': 'https://huggingface.co/spaces/awacke1/Text2SpeechSentimentSave', u'last': text, u'born': date_time,})
|
| 38 |
-
saved = select('Text2SpeechSentimentSave',
|
| 39 |
# check it here: https://console.firebase.google.com/u/0/project/clinical-nlp-b9117/firestore/data/~2FStreamlitSpaces
|
| 40 |
return saved
|
| 41 |
|
|
@@ -45,6 +45,15 @@ def select(collection, document):
|
|
| 45 |
docid = ("The id is: ", doc.id)
|
| 46 |
contents = ("The contents are: ", doc.to_dict())
|
| 47 |
return contents
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
demo = gr.Blocks()
|
| 50 |
|
|
@@ -54,13 +63,16 @@ with demo:
|
|
| 54 |
text = gr.Textbox()
|
| 55 |
label = gr.Label()
|
| 56 |
saved = gr.Textbox()
|
| 57 |
-
|
|
|
|
| 58 |
b1 = gr.Button("Recognize Speech")
|
| 59 |
b2 = gr.Button("Classify Sentiment")
|
| 60 |
b3 = gr.Button("Save Speech to Text")
|
|
|
|
| 61 |
|
| 62 |
b1.click(speech_to_text, inputs=audio_file, outputs=text)
|
| 63 |
b2.click(text_to_sentiment, inputs=text, outputs=label)
|
| 64 |
b3.click(upsert, inputs=text, outputs=saved)
|
| 65 |
-
|
|
|
|
| 66 |
demo.launch(share=True)
|
|
|
|
| 35 |
date_time =str(datetime.datetime.today())
|
| 36 |
doc_ref = db.collection('Text2SpeechSentimentSave').document(date_time)
|
| 37 |
doc_ref.set({u'firefield': 'Recognize Speech', u'first': 'https://huggingface.co/spaces/awacke1/Text2SpeechSentimentSave', u'last': text, u'born': date_time,})
|
| 38 |
+
saved = select('Text2SpeechSentimentSave', date_time)
|
| 39 |
# check it here: https://console.firebase.google.com/u/0/project/clinical-nlp-b9117/firestore/data/~2FStreamlitSpaces
|
| 40 |
return saved
|
| 41 |
|
|
|
|
| 45 |
docid = ("The id is: ", doc.id)
|
| 46 |
contents = ("The contents are: ", doc.to_dict())
|
| 47 |
return contents
|
| 48 |
+
|
| 49 |
+
def selectall(collection):
|
| 50 |
+
docs = db.collection(collection).stream()
|
| 51 |
+
doclist=''
|
| 52 |
+
for doc in docs:
|
| 53 |
+
docid=doc.id
|
| 54 |
+
dict=doc.to_dict()
|
| 55 |
+
doclist+=doc.to_dict()
|
| 56 |
+
return doclist
|
| 57 |
|
| 58 |
demo = gr.Blocks()
|
| 59 |
|
|
|
|
| 63 |
text = gr.Textbox()
|
| 64 |
label = gr.Label()
|
| 65 |
saved = gr.Textbox()
|
| 66 |
+
savedAll = gr.Textbox()
|
| 67 |
+
|
| 68 |
b1 = gr.Button("Recognize Speech")
|
| 69 |
b2 = gr.Button("Classify Sentiment")
|
| 70 |
b3 = gr.Button("Save Speech to Text")
|
| 71 |
+
b4 = gr.Button("Retrieve All")
|
| 72 |
|
| 73 |
b1.click(speech_to_text, inputs=audio_file, outputs=text)
|
| 74 |
b2.click(text_to_sentiment, inputs=text, outputs=label)
|
| 75 |
b3.click(upsert, inputs=text, outputs=saved)
|
| 76 |
+
b4.click(selectall, inputs='Text2SpeechSentimentSave', outputs=savedAll)
|
| 77 |
+
|
| 78 |
demo.launch(share=True)
|