ychenNLP commited on
Commit
e6882db
1 Parent(s): e1e0ec7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -6
app.py CHANGED
@@ -91,15 +91,17 @@ def asr(url):
91
  output = openai.ChatCompletion.create(
92
  model="gpt-3.5-turbo",
93
  messages=[
94
- {"role": "user", "content": "Transcript: {transcript}. \n Translate the video conversation transcript into fluent Chinese. Chinese: ".format(transcript=transcript)},
95
- ]
 
 
96
  )
97
- translation = output['choices'][0]['message']['content']
98
- translations.append(translation)
99
 
100
- yield "请耐心等候翻译:({}/{})...".format(idx+1, len(transcript_chunks)) + " ".join(translations), " ".join(transcripts)
101
 
102
- full_translation = " ".join(translations)
103
  yield full_translation, full_transcript
104
 
105
  title = """
 
91
  output = openai.ChatCompletion.create(
92
  model="gpt-3.5-turbo",
93
  messages=[
94
+ {"role": "user",
95
+ "content": "Transcript: {transcript}. \n Translate the video conversation transcript into fluent Chinese. Chinese: ".format(transcript=transcript)},
96
+ ],
97
+ stream=True,
98
  )
99
+ for event in output:
100
+ translations.append(event["choices"][0].get("delta", "").get("content", ""))
101
 
102
+ yield "请耐心等候翻译:({}/{})...".format(idx+1, len(transcript_chunks)) + "".join(translations), " ".join(transcripts)
103
 
104
+ full_translation = "".join(translations)
105
  yield full_translation, full_transcript
106
 
107
  title = """