Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -100,10 +100,16 @@ classifier = pipeline("text-classification")
|
|
| 100 |
|
| 101 |
def speech_to_text(speech):
|
| 102 |
text = asr(speech)["text"]
|
|
|
|
|
|
|
|
|
|
| 103 |
return text
|
| 104 |
|
| 105 |
def text_to_sentiment(text):
|
| 106 |
sentiment = classifier(text)[0]["label"]
|
|
|
|
|
|
|
|
|
|
| 107 |
return sentiment
|
| 108 |
|
| 109 |
def upsert(text):
|
|
@@ -112,6 +118,9 @@ def upsert(text):
|
|
| 112 |
doc_ref.set({u'firefield': 'Recognize Speech', u'first': 'https://huggingface.co/spaces/awacke1/TTS-STT-Blocks/', u'last': text, u'born': date_time,})
|
| 113 |
saved = select('TTS-STT', date_time)
|
| 114 |
# check it here: https://console.firebase.google.com/u/0/project/clinical-nlp-b9117/firestore/data/~2FStreamlitSpaces
|
|
|
|
|
|
|
|
|
|
| 115 |
return saved
|
| 116 |
|
| 117 |
def select(collection, document):
|
|
@@ -137,6 +146,9 @@ def tts(text: str, model_name: str):
|
|
| 137 |
wavs = synthesizer.tts(text)
|
| 138 |
with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp:
|
| 139 |
synthesizer.save_wav(wavs, fp)
|
|
|
|
|
|
|
|
|
|
| 140 |
return fp.name
|
| 141 |
|
| 142 |
demo = gr.Blocks()
|
|
|
|
| 100 |
|
| 101 |
def speech_to_text(speech):
|
| 102 |
text = asr(speech)["text"]
|
| 103 |
+
|
| 104 |
+
rMem = AIMemory("STT", text)
|
| 105 |
+
|
| 106 |
return text
|
| 107 |
|
| 108 |
def text_to_sentiment(text):
|
| 109 |
sentiment = classifier(text)[0]["label"]
|
| 110 |
+
|
| 111 |
+
rMem = AIMemory(text, sentiment)
|
| 112 |
+
|
| 113 |
return sentiment
|
| 114 |
|
| 115 |
def upsert(text):
|
|
|
|
| 118 |
doc_ref.set({u'firefield': 'Recognize Speech', u'first': 'https://huggingface.co/spaces/awacke1/TTS-STT-Blocks/', u'last': text, u'born': date_time,})
|
| 119 |
saved = select('TTS-STT', date_time)
|
| 120 |
# check it here: https://console.firebase.google.com/u/0/project/clinical-nlp-b9117/firestore/data/~2FStreamlitSpaces
|
| 121 |
+
|
| 122 |
+
rMem = AIMemory(text, saved)
|
| 123 |
+
|
| 124 |
return saved
|
| 125 |
|
| 126 |
def select(collection, document):
|
|
|
|
| 146 |
wavs = synthesizer.tts(text)
|
| 147 |
with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp:
|
| 148 |
synthesizer.save_wav(wavs, fp)
|
| 149 |
+
|
| 150 |
+
rMem = AIMemory("TTS", text + model_name)
|
| 151 |
+
|
| 152 |
return fp.name
|
| 153 |
|
| 154 |
demo = gr.Blocks()
|