awacke1 commited on
Commit
b5a7538
1 Parent(s): 453908a

Update backupapp.py

Browse files
Files changed (1) hide show
  1. backupapp.py +17 -6
backupapp.py CHANGED
@@ -3,7 +3,7 @@ import base64
3
  import glob
4
  import json
5
  import math
6
- import mistune
7
  import openai
8
  import os
9
  import pytz
@@ -13,6 +13,8 @@ import streamlit as st
13
  import textract
14
  import time
15
  import zipfile
 
 
16
  from audio_recorder_streamlit import audio_recorder
17
  from bs4 import BeautifulSoup
18
  from collections import deque
@@ -113,6 +115,7 @@ def StreamLLMChatResponse(prompt):
113
  res_box = st.empty()
114
  collected_chunks=[]
115
  collected_messages=[]
 
116
  for r in stream:
117
  if r.token.special:
118
  continue
@@ -126,8 +129,12 @@ def StreamLLMChatResponse(prompt):
126
  if len(r.token.text) > 0:
127
  result="".join(report).strip()
128
  res_box.markdown(f'*{result}*')
 
129
  except:
130
- st.write(' ')
 
 
 
131
  except:
132
  st.write('DromeLlama is asleep. Starting up now on A10 - please give 5 minutes then retry as KEDA scales up from zero to activate running container(s).')
133
 
@@ -388,7 +395,7 @@ def get_zip_download_link(zip_file):
388
  return href
389
 
390
 
391
- API_URL = f'https://tonpixzfvq3791u9.us-east-1.aws.endpoints.huggingface.cloud'
392
  headers = {
393
  "Authorization": "Bearer XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
394
  "Content-Type": "audio/wav"
@@ -397,7 +404,7 @@ headers = {
397
  def query(filename):
398
  with open(filename, "rb") as f:
399
  data = f.read()
400
- response = requests.post(API_URL, headers=headers, data=data)
401
  return response.json()
402
 
403
  def generate_filename(prompt, file_type):
@@ -422,7 +429,6 @@ def transcribe_audio(filename):
422
  output = query(filename)
423
  return output
424
 
425
-
426
  def whisper_main():
427
  st.title("Speech to Text")
428
  st.write("Record your speech and get the text.")
@@ -432,7 +438,12 @@ def whisper_main():
432
  if filename is not None:
433
  transcription = transcribe_audio(filename)
434
  st.write(transcription)
435
-
 
 
 
 
 
436
 
437
  def main():
438
 
 
3
  import glob
4
  import json
5
  import math
6
+ #import mistune
7
  import openai
8
  import os
9
  import pytz
 
13
  import textract
14
  import time
15
  import zipfile
16
+ import huggingface_hub
17
+ import dotenv
18
  from audio_recorder_streamlit import audio_recorder
19
  from bs4 import BeautifulSoup
20
  from collections import deque
 
115
  res_box = st.empty()
116
  collected_chunks=[]
117
  collected_messages=[]
118
+ #allresults=''
119
  for r in stream:
120
  if r.token.special:
121
  continue
 
129
  if len(r.token.text) > 0:
130
  result="".join(report).strip()
131
  res_box.markdown(f'*{result}*')
132
+ #allresults=allresults+result
133
  except:
134
+ st.write('Stream llm issue')
135
+
136
+ #st.write(allresults)
137
+ #return allresults
138
  except:
139
  st.write('DromeLlama is asleep. Starting up now on A10 - please give 5 minutes then retry as KEDA scales up from zero to activate running container(s).')
140
 
 
395
  return href
396
 
397
 
398
+ API_URL_IE = f'https://tonpixzfvq3791u9.us-east-1.aws.endpoints.huggingface.cloud'
399
  headers = {
400
  "Authorization": "Bearer XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
401
  "Content-Type": "audio/wav"
 
404
  def query(filename):
405
  with open(filename, "rb") as f:
406
  data = f.read()
407
+ response = requests.post(API_URL_IE, headers=headers, data=data)
408
  return response.json()
409
 
410
  def generate_filename(prompt, file_type):
 
429
  output = query(filename)
430
  return output
431
 
 
432
  def whisper_main():
433
  st.title("Speech to Text")
434
  st.write("Record your speech and get the text.")
 
438
  if filename is not None:
439
  transcription = transcribe_audio(filename)
440
  st.write(transcription)
441
+ response = StreamLLMChatResponse(transcription['text'])
442
+ st.write(response)
443
+ #filename = generate_filename(str(response), ".txt")
444
+ #st.write(filename)
445
+ #create_file(filename, transcription, '', True)
446
+ #st.sidebar.markdown(get_table_download_link(filename), unsafe_allow_html=True)
447
 
448
  def main():
449