Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 14126

Why isn'it working ?? Pygame ModPlug_Load failed I want it like Jarvis

$
0
0

[[enter image description here](https://i.stack.imgur.com/HzAaP.png)](https://i.stack.imgur.com/RzpLL.png)

Concept from : https://youtu.be/e_nKCZe6Ikc?t=161

I try to run this code, I ask Chat gpt to help but nothing, it worked one time but now he dont want to. I have this error :

ModPlug_Load failed  File "C:\Users\widac\Documents\Jarvis perso\log_in_speach.py", line 45, in speak    pygame.mixer.music.load(audio_bytes)  File "C:\Users\widac\Documents\Jarvis perso\log_in_speach.py", line 55, in <module>    speak("Hello sir, pasword please ?")pygame.error: ModPlug_Load failed

This is the code :

import subprocessimport osimport pywhatkitimport customtkinterimport pyttsx3import speech_recognition as srimport elevenlabsimport requestsimport pygamefrom io import BytesIO# API endpoint and parametersurl = "https://api.elevenlabs.io/v1/text-to-speech/CYw3kZ02Hs0563khs1Fj/stream"querystring = {"output_format": "mp3_44100_128", "optimize_streaming_latency": "2"}# Function to convert text to speech using Eleven Labs APIdef speak(text):    # Payload for the API request    payload = {"text": text,"voice_settings": {"similarity_boost": 1,"use_speaker_boost": False,"style": 0.18,"stability": 0.8        }    }    # Headers for the API request    headers = {"xi-api-key": "684da13834df1f125e7989bb92158e01","Content-Type": "application/json"    }    # Sending request to the API    response = requests.request("POST", url, json=payload, headers=headers, params=querystring)    # Extracting audio content    audio_bytes = BytesIO(response.content)    # Initialize pygame mixer    pygame.mixer.init()    # Load the audio    pygame.mixer.music.load(audio_bytes)    # Play the audio    pygame.mixer.music.play()    # Wait until the music finishes playing    while pygame.mixer.music.get_busy():        pygame.time.Clock().tick(10)speak("Hello sir, pasword please ?")recognizer = sr.Recognizer()try:    with sr.Microphone() as source:        while True:            print("J'écoute...\n")            voice = recognizer.listen(source)            command = recognizer.recognize_google(voice, language='fr-FR')            if command == "2742":                print("welcome sir, happy to see you!")                speak("welcome sir, happy to see you!")                break            else:                print('Sir? Is that you ?')                speak('Sir? Is that you ?')except Exception:    print('sorry')    speak("sorry")

I try to run this code, I ask Chat gpt to help but nothing, it worked one time, i colsed my pc, and now he dont want to. I tried so hard now I just cant find how! I use VS Code with python 3.11 instaled in microsoft store. I want my code toconnect to a voice in elevenlabs ans peak to me with this voice and I can speak to him too.


Viewing all articles
Browse latest Browse all 14126

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>