Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def play_piano_C2_7():
playsound('music/piano/C2_7.mp3')
def play_piano_C1_7():
playsound('music/piano/C1_7.mp3')
display.blit(advt, (970, 350))
# print(lang)
pygame.display.update()
if closestLabel:
if(closestLabel in vehicles and closestDist < 17*10):
if(lang==0):
playsound("./sounds/vehicle_ahead_hi.mp3")
elif(lang==1):
playsound("./sounds/vehicle_ahead_en.mp3")
elif(lang==2):
playsound("./sounds/vehicle_ahead_mh.mp3")
elif(lang==3):
playsound("./sounds/vehicle_ahead_bn.mp3")
else:
if(closestLabel=="stop sign"):
if(lang==0):
playsound("./sounds/stop_hi.mp3")
elif(lang==1):
playsound("./sounds/stop_en.mp3")
elif(lang==2):
playsound("./sounds/stop_mh.mp3")
elif(lang==3):
playsound("./sounds/stop_bn.mp3")
elif(closestLabel=="turn left"):
if(lang==0):
playsound("./sounds/tl_hi.mp3")
elif(lang==1):
playsound("./sounds/tl_en.mp3")
elif(lang==2):
def say(text):
# this is an alternative solution and is NOT fast
# on RPi aiy.tts
# on Windows win32com speech engine
# on Mac standard preinstalled 'say'
# on Linux gTTS: bad and slow
AI.log("(!) long delay because of bad TTS solution: much better on Windows, RPi, Mac")
# tts
with NamedTemporaryFile() as f:
# google server request
tts = gTTS(text=text, lang=AI.settings.language.split("-")[0])
# save received file
tts.save(f.name+".mp3")
# play
playsound.playsound(f.name+".mp3")
def playaudio(self, filename, block):
if self._option == 0:
from playsound import playsound # lazy loading
#print("playsound")
playsound(filename, block)
else:
pass
def speak(audio_string):
tts = gTTS(text=audio_string, lang='en') # text to speech(voice)
r = random.randint(1,20000000)
audio_file = 'audio' + str(r) + '.mp3'
tts.save(audio_file) # save as mp3
playsound.playsound(audio_file) # play the audio file
print(f"kiri: {audio_string}") # print what app said
os.remove(audio_file) # remove audio file
playsound("./sounds/vehicle_ahead_mh.mp3")
elif(lang==3):
playsound("./sounds/vehicle_ahead_bn.mp3")
else:
if(closestLabel=="stop sign"):
if(lang==0):
playsound("./sounds/stop_hi.mp3")
elif(lang==1):
playsound("./sounds/stop_en.mp3")
elif(lang==2):
playsound("./sounds/stop_mh.mp3")
elif(lang==3):
playsound("./sounds/stop_bn.mp3")
elif(closestLabel=="turn left"):
if(lang==0):
playsound("./sounds/tl_hi.mp3")
elif(lang==1):
playsound("./sounds/tl_en.mp3")
elif(lang==2):
playsound("./sounds/tl_mh.mp3")
elif(lang==3):
playsound("./sounds/tl_bn.mp3")
elif(closestLabel=="turn right"):
if(lang==0):
playsound("./sounds/tr_hi.mp3")
elif(lang==1):
playsound("./sounds/tr_en.mp3")
elif(lang==2):
playsound("./sounds/tr_mh.mp3")
elif(lang==3):
playsound("./sounds/tr_bn.mp3")
if closestLabel:
if(closestLabel in vehicles and closestDist < 17*10):
if(lang==0):
playsound("./sounds/vehicle_ahead_hi.mp3")
elif(lang==1):
playsound("./sounds/vehicle_ahead_en.mp3")
elif(lang==2):
playsound("./sounds/vehicle_ahead_mh.mp3")
elif(lang==3):
playsound("./sounds/vehicle_ahead_bn.mp3")
else:
if(closestLabel=="stop sign"):
if(lang==0):
playsound("./sounds/stop_hi.mp3")
elif(lang==1):
playsound("./sounds/stop_en.mp3")
elif(lang==2):
playsound("./sounds/stop_mh.mp3")
elif(lang==3):
playsound("./sounds/stop_bn.mp3")
elif(closestLabel=="turn left"):
if(lang==0):
playsound("./sounds/tl_hi.mp3")
elif(lang==1):
playsound("./sounds/tl_en.mp3")
elif(lang==2):
playsound("./sounds/tl_mh.mp3")
elif(lang==3):
playsound("./sounds/tl_bn.mp3")
elif(closestLabel=="turn right"):
if(lang==0):
playsound("./sounds/tr_hi.mp3")
playsound("./sounds/vehicle_ahead_bn.mp3")
else:
if(closestLabel=="stop sign"):
if(lang==0):
playsound("./sounds/stop_hi.mp3")
elif(lang==1):
playsound("./sounds/stop_en.mp3")
elif(lang==2):
playsound("./sounds/stop_mh.mp3")
elif(lang==3):
playsound("./sounds/stop_bn.mp3")
elif(closestLabel=="turn left"):
if(lang==0):
playsound("./sounds/tl_hi.mp3")
elif(lang==1):
playsound("./sounds/tl_en.mp3")
elif(lang==2):
playsound("./sounds/tl_mh.mp3")
elif(lang==3):
playsound("./sounds/tl_bn.mp3")
elif(closestLabel=="turn right"):
if(lang==0):
playsound("./sounds/tr_hi.mp3")
elif(lang==1):
playsound("./sounds/tr_en.mp3")
elif(lang==2):
playsound("./sounds/tr_mh.mp3")
elif(lang==3):
playsound("./sounds/tr_bn.mp3")
clock.tick(60)
def speak_this(text_speak):
tts = gTTS(text_speak)
tts.save('speech.mp3')
playsound('speech.mp3')
os.remove('speech.mp3')