Les comparto un code para reproducir música y video en youtube con alexa. Funciona correctamente.

Imagen
Imagen
Code:

Código: Seleccionar todo

import speech_recognition as sr import pyttsx3 name = 'voz' listener = sr.Recognizer() engine = pyttsx3.init() voices = engine.getProperty('voices') engine.setProperty('voice', voices [1].id) def talk(text): engine.say(text) engine.runAndWait() def listen(): try: with sr.Microphone() as source: print('Escuchando') voice = listener.listen(source) rec = listener.recognize_google(voice) rec = rec.lower() if name in rec: rec = rec.replace(name, '') print(rec) except: pass return rec def run(): rec = listen() if 'reproduce' in rec: music = rec.replace('reproduce', '') talk('reproduciendo' +music) pywhatkit.playonyt(music) run() 
Paquetes necesarios:

● Package1: SpeechRecognition [ [Enlace externo eliminado para invitados]... ]
Command: pip install SpeechRecognition

● Package 2: pyttsx3 [ [Enlace externo eliminado para invitados] ]
Command: pip install pyttsx3

● Package 3: PyAudio [ [Enlace externo eliminado para invitados] ]
Command: pip install PyAudio
If you got an error (in package 3) just like in the video, you can download the .whl file here:

[Enlace externo eliminado para invitados]...

● Package 4: pywhatkit [ [Enlace externo eliminado para invitados] ]
Command: pip install pywhatkit

Fuente:

AVM
 
Imagen
Imagen
Responder

Volver a “Fuentes”