takarajordan commited on
Commit
371f592
1 Parent(s): 9f6f605

refactor: simplify text validation

Browse files

Replace explicit text validation with simpler 'if text:' check that handles
all falsy cases (None, empty string, whitespace) while maintaining the same
functionality.

Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -208,7 +208,7 @@ def transcribe_and_stream(inputs, model_name="groq_whisper", show_info="show_inf
208
 
209
 
210
  def aya_speech_text_response(text):
211
- if text is not None and text!="":
212
  stream = audio_response_client.chat_stream(message=text,preamble=AUDIO_RESPONSE_PREAMBLE, model=AYA_MODEL_NAME)
213
  output = ""
214
 
@@ -236,7 +236,7 @@ def clean_text(text, remove_bullets=False, remove_newline=False):
236
  def convert_text_to_speech(text, language="english"):
237
 
238
  # do language detection to determine voice of speech response
239
- if text is not None and text!="":
240
  # clean text before doing language detection
241
  cleaned_text = clean_text(text, remove_bullets=True, remove_newline=True)
242
  text_lang_code = predict_language(cleaned_text)
 
208
 
209
 
210
  def aya_speech_text_response(text):
211
+ if text:
212
  stream = audio_response_client.chat_stream(message=text,preamble=AUDIO_RESPONSE_PREAMBLE, model=AYA_MODEL_NAME)
213
  output = ""
214
 
 
236
  def convert_text_to_speech(text, language="english"):
237
 
238
  # do language detection to determine voice of speech response
239
+ if text:
240
  # clean text before doing language detection
241
  cleaned_text = clean_text(text, remove_bullets=True, remove_newline=True)
242
  text_lang_code = predict_language(cleaned_text)