son9john commited on
Commit
cefae98
·
1 Parent(s): 7946524

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -37
app.py CHANGED
@@ -1,26 +1,15 @@
1
- import os
2
- os.system("python -m pip install --upgrade pip")
3
  import openai
4
  import gradio as gr
5
  from gradio.components import Audio, Textbox
 
6
  import re
7
  import tiktoken
8
-
9
  import whisper
 
10
  from datetime import datetime, timezone, timedelta
11
  import notion_df
12
  import concurrent.futures
13
- from IPython.core.display import HTML
14
- os.system("pip install transformers>=4.0.0 pandas numpy spacy")
15
- from transformers import GPT2Tokenizer
16
- import pandas as pd
17
- import numpy as np
18
- import spacy
19
-
20
-
21
- from spacy import displacy
22
-
23
- nlp = spacy.load("en_core_web_sm")
24
 
25
  # Define the tokenizer and model
26
  tokenizer = GPT2Tokenizer.from_pretrained('gpt2-medium')
@@ -137,32 +126,14 @@ def transcribe(audio, text):
137
  df = pd.DataFrame([chat_transcript])
138
  notion_df.upload(df, 'https://www.notion.so/YENA-be569d0a40c940e7b6e0679318215790?pvs=4', title=str(published_date), api_key=API_KEY)
139
 
140
- # Colorize the system message text
141
- colorized_system_message = colorize_text(system_message['content'])
142
-
143
- # Return the colorized chat transcript
144
- return colorized_system_message
145
-
146
 
147
- def colorize_text(text):
148
- doc = nlp(text)
149
- colorized_text = ""
150
-
151
- for token in doc:
152
- if token.ent_type_:
153
- colorized_text += f'<span style="background-color: yellow;">{token.text_with_ws}</span>'
154
- elif token.pos_ in {'NOUN'}:
155
- colorized_text += f'<span style="color: blue;">{token.text_with_ws}</span>'
156
- else:
157
- colorized_text += token.text_with_ws
158
-
159
- return colorized_text
160
-
161
-
162
  # Define the input and output components for Gradio
163
  audio_input = Audio(source="microphone", type="filepath", label="Record your message")
164
  text_input = Textbox(label="Type your message", max_length=4096)
165
- output_text = Markdown()
 
166
 
167
  # Define the Gradio interface
168
  iface = gr.Interface(
@@ -177,4 +148,4 @@ iface = gr.Interface(
177
  )
178
 
179
  # Run the Gradio interface
180
- iface.launch(enable_queue=True)
 
 
 
1
  import openai
2
  import gradio as gr
3
  from gradio.components import Audio, Textbox
4
+ import os
5
  import re
6
  import tiktoken
7
+ from transformers import GPT2Tokenizer
8
  import whisper
9
+ import pandas as pd
10
  from datetime import datetime, timezone, timedelta
11
  import notion_df
12
  import concurrent.futures
 
 
 
 
 
 
 
 
 
 
 
13
 
14
  # Define the tokenizer and model
15
  tokenizer = GPT2Tokenizer.from_pretrained('gpt2-medium')
 
126
  df = pd.DataFrame([chat_transcript])
127
  notion_df.upload(df, 'https://www.notion.so/YENA-be569d0a40c940e7b6e0679318215790?pvs=4', title=str(published_date), api_key=API_KEY)
128
 
129
+ # Return the chat transcript
130
+ return system_message['content']
 
 
 
 
131
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
132
  # Define the input and output components for Gradio
133
  audio_input = Audio(source="microphone", type="filepath", label="Record your message")
134
  text_input = Textbox(label="Type your message", max_length=4096)
135
+ output_text = gr.outputs.Textbox(label="Response")
136
+ output_audio = Audio()
137
 
138
  # Define the Gradio interface
139
  iface = gr.Interface(
 
148
  )
149
 
150
  # Run the Gradio interface
151
+ iface.launch()