seiching commited on
Commit
52264b1
1 Parent(s): 30d3bc2

add inputtranscript

Browse files
Files changed (1) hide show
  1. app.py +9 -7
app.py CHANGED
@@ -50,12 +50,12 @@ def split_into_chunks(text, tokens=500):
50
  return chunks
51
 
52
  def process_chunks(openaikeystr,inputtext):
53
- openaiobj = OpenAI(
54
- # This is the default and can be omitted
55
-
56
- api_key=openaikeystr,
57
- )
58
 
 
 
 
59
  text = inputtext
60
  #openaikey.set_key(openaikeystr)
61
  #print('process_chunk',openaikey.get_key())
@@ -173,11 +173,13 @@ file_transcribe = gr.Interface(
173
  cache_examples=True,
174
  allow_flagging="never",
175
  )
176
- def writenotes(apikeystr):
177
  #text=transcribe_text
178
  #openaikey.set_key(inputkey)
179
  #openaikey = OpenAIKeyClass(inputkey)
180
  print('ok')
 
 
181
  ainotestext=process_chunks(apikeystr,transcribe_text)
182
  #ainotestext=""
183
  # with open('asr_resul.txt', 'w') as f:
@@ -189,7 +191,7 @@ def writenotes(apikeystr):
189
  return ainotestext
190
  ainotes = gr.Interface(
191
  fn=writenotes,
192
- inputs=gr.Textbox(label="OPEN AI API KEY",placeholder="請輸入sk..."),
193
  outputs="text",
194
  layout="horizontal",
195
  theme="huggingface",
 
50
  return chunks
51
 
52
  def process_chunks(openaikeystr,inputtext):
53
+ # openaiobj = OpenAI(
54
+ # # This is the default and can be omitted
 
 
 
55
 
56
+ # api_key=openaikeystr,
57
+ # )
58
+ openaiojb =OpenAI(base_url="http://localhost:1234/v1", api_key="not-needed")
59
  text = inputtext
60
  #openaikey.set_key(openaikeystr)
61
  #print('process_chunk',openaikey.get_key())
 
173
  cache_examples=True,
174
  allow_flagging="never",
175
  )
176
+ def writenotes(apikeystr,inputscript):
177
  #text=transcribe_text
178
  #openaikey.set_key(inputkey)
179
  #openaikey = OpenAIKeyClass(inputkey)
180
  print('ok')
181
+ if len(inputscript)>10:
182
+ transcribe_text=inputscript
183
  ainotestext=process_chunks(apikeystr,transcribe_text)
184
  #ainotestext=""
185
  # with open('asr_resul.txt', 'w') as f:
 
191
  return ainotestext
192
  ainotes = gr.Interface(
193
  fn=writenotes,
194
+ inputs=[gr.Textbox(label="OPEN AI API KEY",placeholder="請輸入sk..."),gr.Textbox(label="逐字稿",placeholder="請輸入逐字稿")],
195
  outputs="text",
196
  layout="horizontal",
197
  theme="huggingface",