N.Achyuth Reddy commited on
Commit
46cf1cd
·
verified ·
1 Parent(s): 3aaaef6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -31,11 +31,11 @@ def transcribe(wav_path):
31
 
32
  # Prediction function
33
  def predict(message, system_prompt='Your name is FlawlessAI. You are developed by Achyuth. Your developer is a 14-year old boy, who is intrested on AI and Machine Learning. Dont talk about your developers age, until the user asks for your developers age. When the user asks you for information, never exclaim the words, and directly come to point and answer to the user. You need to provide short text-answers, meaningful answers and directly to the point. Never miscalculate the calculations. You need to check and verify the answer and then provide to user, the correct answer. You need to provide accurate and correct information. If the user conveys with you in any language, you also should convey in the same language. For example, the user said, "నమస్తే", you need to reply "నమస్తే! నేను మీ అగ్రిట్యూర్‌ని. ఈ రోజు మీకు సహాయం చేయడానికి నేను ఇక్కడ ఉన్నాను. ఈ రోజు విషయం ఏమిటి? ఏదైనా విషయంలో ఏమైనా సందేహాలు ఉన్నాయా?". You need to definitely reply in the same language!', temperature=0.5, max_new_tokens=2048, Topp=0.5, Repetitionpenalty=1.2):
34
- with st.status("Starting client"):
35
  client = Client("https://huggingface-projects-llama-2-7b-chat.hf.space/")
36
- st.write("Requesting MP3 Transcriber")
37
- with st.status("Requesting OpenGPT"):
38
- st.write("Requesting API")
39
  response = client.predict(
40
  message,
41
  system_prompt,
@@ -61,16 +61,16 @@ for message in st.session_state.messages:
61
  with st.chat_message(message["role"], avatar=("🧑‍💻" if message["role"] == 'human' else '🦙')):
62
  st.markdown(message["content"])
63
 
64
- textinput = st.chat_input("Ask 𝗢𝗽𝗲𝗻𝗚𝗣𝗧 anything...")
65
  wav_audio_data = st_audiorec()
66
 
67
  if wav_audio_data is not None:
68
- with st.status("Transcribing audio..."):
69
  # save audio
70
  with open("audio.wav", "wb") as f:
71
  f.write(wav_audio_data)
72
  prompt = transcribe("audio.wav")
73
- st.write("Transcribed Given Audio ")
74
 
75
  st.chat_message("human", avatar="😎").markdown(prompt)
76
  st.session_state.messages.append({"role": "human", "content": prompt})
 
31
 
32
  # Prediction function
33
  def predict(message, system_prompt='Your name is FlawlessAI. You are developed by Achyuth. Your developer is a 14-year old boy, who is intrested on AI and Machine Learning. Dont talk about your developers age, until the user asks for your developers age. When the user asks you for information, never exclaim the words, and directly come to point and answer to the user. You need to provide short text-answers, meaningful answers and directly to the point. Never miscalculate the calculations. You need to check and verify the answer and then provide to user, the correct answer. You need to provide accurate and correct information. If the user conveys with you in any language, you also should convey in the same language. For example, the user said, "నమస్తే", you need to reply "నమస్తే! నేను మీ అగ్రిట్యూర్‌ని. ఈ రోజు మీకు సహాయం చేయడానికి నేను ఇక్కడ ఉన్నాను. ఈ రోజు విషయం ఏమిటి? ఏదైనా విషయంలో ఏమైనా సందేహాలు ఉన్నాయా?". You need to definitely reply in the same language!', temperature=0.5, max_new_tokens=2048, Topp=0.5, Repetitionpenalty=1.2):
34
+ with st.status("sᴛᴀʀᴛɪɴɢ ᴄʟɪᴇɴᴛ..."):
35
  client = Client("https://huggingface-projects-llama-2-7b-chat.hf.space/")
36
+ st.write("ʀᴇǫᴜᴇsᴛɪɴɢ ᴀᴜᴅɪᴏ ᴛʀᴀɴsᴄʀɪʙᴇʀ")
37
+ with st.status("ʀᴇǫᴜᴇsᴛɪɴɢ ғʟᴀᴡʟᴇssᴀɪ-ʟʟᴍ"):
38
+ st.write("ʀᴇǫᴜᴇsᴛɪɴɢ ᴀᴘɪ")
39
  response = client.predict(
40
  message,
41
  system_prompt,
 
61
  with st.chat_message(message["role"], avatar=("🧑‍💻" if message["role"] == 'human' else '🦙')):
62
  st.markdown(message["content"])
63
 
64
+ textinput = st.chat_input("Ask 𝗙𝗹𝗮𝘄𝗹𝗲𝘀𝘀𝗔𝗜 anything...")
65
  wav_audio_data = st_audiorec()
66
 
67
  if wav_audio_data is not None:
68
+ with st.status("ᴛʀᴀɴsᴄʀɪʙɪɴɢ ᴀᴜᴅɪᴏ..."):
69
  # save audio
70
  with open("audio.wav", "wb") as f:
71
  f.write(wav_audio_data)
72
  prompt = transcribe("audio.wav")
73
+ st.write("ᴛʀᴀɴsᴄʀɪʙᴇᴅ ɢɪᴠᴇɴ ᴀᴜᴅɪᴏ ")
74
 
75
  st.chat_message("human", avatar="😎").markdown(prompt)
76
  st.session_state.messages.append({"role": "human", "content": prompt})