awacke1 commited on
Commit
215cca8
1 Parent(s): cc5cc4f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -2
app.py CHANGED
@@ -1,16 +1,48 @@
 
 
 
 
 
1
  from transformers import pipeline
2
-
3
  import gradio as gr
4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  asr = pipeline("automatic-speech-recognition", "facebook/wav2vec2-base-960h")
6
  classifier = pipeline("text-classification")
7
 
8
  def speech_to_text(speech):
9
  text = asr(speech)["text"]
 
10
  return text
11
 
12
  def text_to_sentiment(text):
13
- return classifier(text)[0]["label"]
 
 
14
 
15
  demo = gr.Blocks()
16
 
 
1
+ import streamlit as st
2
+ import firebase_admin
3
+ from firebase_admin import credentials
4
+ from firebase_admin import firestore
5
+ from datetime import datetime
6
  from transformers import pipeline
 
7
  import gradio as gr
8
 
9
+ @st.experimental_singleton
10
+ def get_db_firestore():
11
+ cred = credentials.Certificate('test.json')
12
+ firebase_admin.initialize_app(cred, {'projectId': u'clinical-nlp-b9117',})
13
+ db = firestore.client()
14
+ return db
15
+
16
+ def upsertoftheminute(collection, document, firefield, first, last, born):
17
+ date_time = now.strftime("%m/%d/%Y, %H:%M")
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/FirestorePersistence', 2022)
30
+ selectCollectionDocument(u"TimeSeries", u"DocumentofMinute")
31
+
32
+
33
+
34
  asr = pipeline("automatic-speech-recognition", "facebook/wav2vec2-base-960h")
35
  classifier = pipeline("text-classification")
36
 
37
  def speech_to_text(speech):
38
  text = asr(speech)["text"]
39
+ upsertoftheminute(u'TimeSeries', u'DocumentofMinuteText', u'TestUser1', u'🧠🌳Yggdrasil🌳🧠', text, 2022)
40
  return text
41
 
42
  def text_to_sentiment(text):
43
+ sentiment = classifier(text)[0]["label"]
44
+ upsertoftheminute(u'TimeSeries', u'DocumentofMinuteSentiment', u'TestUser1', u'🧠🌳Yggdrasil🌳🧠', sentiment, 2022)
45
+ return sentiment
46
 
47
  demo = gr.Blocks()
48