How to use the playsound.playsound function in playsound

To help you get started, we’ve selected a few playsound examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dark-archerx / Traffic-Signs-and-Object-Detection / main.py View on Github external
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):
github matthiaaas / otto-assistant / linux / ai.py View on Github external
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")
github richmondu / libfaceid / libfaceid / speech_synthesizer.py View on Github external
def playaudio(self, filename, block):
        if self._option == 0:
            from playsound import playsound # lazy loading
            #print("playsound")
            playsound(filename, block)
        else:
            pass
github bradtraversy / alexis_speech_assistant / main.py View on Github external
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
github dark-archerx / Traffic-Signs-and-Object-Detection / main.py View on Github external
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")
github dark-archerx / Traffic-Signs-and-Object-Detection / main.py View on Github external
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")
github dark-archerx / Traffic-Signs-and-Object-Detection / main.py View on Github external
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)
github ugroot / GROOT / texttospeech.py View on Github external
def speak_this(text_speak):
	tts = gTTS(text_speak)
	tts.save('speech.mp3')
	playsound('speech.mp3')
	os.remove('speech.mp3')