amir22010 commited on
Commit
d65efa8
·
verified ·
1 Parent(s): 7e32857

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -10
app.py CHANGED
@@ -101,16 +101,13 @@ async def greet(product,description):
101
  if response.choices[0].message.content != "not moderated":
102
  a_list = ["Sorry, I can't proceed for generating marketing email. Your content needs to be moderated first. Thank you!"]
103
  with locker:
104
- print(os.system("ls"))
105
- print(os.system("pwd"))
106
- print(os.path.join(os.getcwd(), tts_model_str))
107
  tts = TTS(os.path.join(os.getcwd(), tts_model_str))
108
  speakers = tts.get_speakers()
109
- model_to_speakers = dict()
110
- model_to_speakers[tts_model_str] = speakers
111
- print(speakers)
112
- samples = tts.synthesize(a_list[0], speakers[-1])
113
- yield (tts.get_sampling_rate(), samples)
114
  else:
115
  output = llm.create_chat_completion(
116
  messages=[
@@ -131,8 +128,6 @@ async def greet(product,description):
131
  with locker:
132
  tts = TTS(os.path.join(os.getcwd(), tts_model_str))
133
  speakers = tts.get_speakers()
134
- model_to_speakers = dict()
135
- model_to_speakers[tts_model_str] = speakers
136
  samples = tts.synthesize(delta.get('content', ''), speakers[-1])
137
  yield (tts.get_sampling_rate(), samples)
138
 
 
101
  if response.choices[0].message.content != "not moderated":
102
  a_list = ["Sorry, I can't proceed for generating marketing email. Your content needs to be moderated first. Thank you!"]
103
  with locker:
 
 
 
104
  tts = TTS(os.path.join(os.getcwd(), tts_model_str))
105
  speakers = tts.get_speakers()
106
+ if len(a_list[0]) > 1024:
107
+ # truncate the text
108
+ text_str = a_list[0][:1024]
109
+ samples = tts.synthesize(text_str, speakers[-1])
110
+ yield gr.Audio.update(value=(tts.get_sampling_rate(), samples))
111
  else:
112
  output = llm.create_chat_completion(
113
  messages=[
 
128
  with locker:
129
  tts = TTS(os.path.join(os.getcwd(), tts_model_str))
130
  speakers = tts.get_speakers()
 
 
131
  samples = tts.synthesize(delta.get('content', ''), speakers[-1])
132
  yield (tts.get_sampling_rate(), samples)
133