awacke1 commited on
Commit
c89df82
1 Parent(s): 14c2ff3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -13
app.py CHANGED
@@ -13,18 +13,7 @@ def get_db_firestore():
13
  db = firestore.client()
14
  return db
15
 
16
- def upsertoftheminute(collection, document, firefield, first, last, born):
17
- date_time =str(datetime.datetime.today()).split()[0]
18
- doc_ref = db.collection(collection).document(document)
19
- doc_ref.set({u'firefield': firefield, u'first': first, u'last': last, u'born': date_time,})
20
-
21
- def selectCollectionDocument(collection, document):
22
- doc_ref = db.collection(collection).document(document)
23
- doc = doc_ref.get()
24
- st.write("The id is: ", doc.id)
25
- st.write("The contents are: ", doc.to_dict())
26
-
27
-
28
  db = get_db_firestore()
29
  upsertoftheminute(u'TimeSeries', u'DocumentofMinute', u'TestUser1', u'🧠🌳Yggdrasil🌳🧠', u'https://huggingface.co/spaces/awacke1/Text2SpeechSentimentSave', 2022)
30
  selectCollectionDocument(u"TimeSeries", u"DocumentofMinute")
@@ -55,6 +44,21 @@ def text_to_sentiment(text):
55
  upsertoftheminute(u'TimeSeries', u'DocumentofMinuteSentiment', u'TestUser1', u'🧠🌳Yggdrasil🌳🧠', sentiment, 2022)
56
  return sentiment
57
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  demo = gr.Blocks()
59
 
60
  with demo:
@@ -62,11 +66,14 @@ with demo:
62
  audio_file = gr.inputs.Audio(source="microphone", type="filepath")
63
  text = gr.Textbox()
64
  label = gr.Label()
 
65
 
66
  b1 = gr.Button("Recognize Speech")
67
  b2 = gr.Button("Classify Sentiment")
 
68
 
69
  b1.click(speech_to_text, inputs=audio_file, outputs=text)
70
  b2.click(text_to_sentiment, inputs=text, outputs=label)
 
71
 
72
- demo.launch()
 
13
  db = firestore.client()
14
  return db
15
 
16
+
 
 
 
 
 
 
 
 
 
 
 
17
  db = get_db_firestore()
18
  upsertoftheminute(u'TimeSeries', u'DocumentofMinute', u'TestUser1', u'🧠🌳Yggdrasil🌳🧠', u'https://huggingface.co/spaces/awacke1/Text2SpeechSentimentSave', 2022)
19
  selectCollectionDocument(u"TimeSeries", u"DocumentofMinute")
 
44
  upsertoftheminute(u'TimeSeries', u'DocumentofMinuteSentiment', u'TestUser1', u'🧠🌳Yggdrasil🌳🧠', sentiment, 2022)
45
  return sentiment
46
 
47
+ def upsert(text):
48
+ date_time =str(datetime.datetime.today()).split()[0]
49
+ doc_ref = db.collection('Text2SpeechSentimentSave').document('Text2SpeechSentimentSave')
50
+ doc_ref.set({u'firefield': 'Text2SpeechSentimentSave', u'first': 'Text2SpeechSentimentSave', u'last': 'Text2SpeechSentimentSave', u'born': date_time,})
51
+ saved = select('Text2SpeechSentimentSave','Text2SpeechSentimentSave')
52
+ return saved
53
+
54
+ def select(collection, document):
55
+ doc_ref = db.collection(collection).document(document)
56
+ doc = doc_ref.get()
57
+ docid = ("The id is: ", doc.id)
58
+ contents = ("The contents are: ", doc.to_dict())
59
+ return contents
60
+
61
+
62
  demo = gr.Blocks()
63
 
64
  with demo:
 
66
  audio_file = gr.inputs.Audio(source="microphone", type="filepath")
67
  text = gr.Textbox()
68
  label = gr.Label()
69
+ saved = gr.Label()
70
 
71
  b1 = gr.Button("Recognize Speech")
72
  b2 = gr.Button("Classify Sentiment")
73
+ b3 = gr.Button("Save Speech to Text")
74
 
75
  b1.click(speech_to_text, inputs=audio_file, outputs=text)
76
  b2.click(text_to_sentiment, inputs=text, outputs=label)
77
+ b3.click(text_to_sentiment, inputs=text, outputs=saved)
78
 
79
+ demo.launch(share=True)