Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

import speech_recognition as sr

import pyttsx3
import google.auth
from google.assistant.embedded.v1alpha2 import (
embedded_assistant_pb2,
embedded_assistant_pb2_grpc
)

# Set up the text-to-speech engine


engine = pyttsx3.init()

# Set up the speech recognition module


r = sr.Recognizer()

# Set up the Google Assistant API client


credentials, project_id = google.auth.default()
assistant = embedded_assistant_pb2_grpc.EmbeddedAssistantStub(
channel=google.auth.transport.grpc.secure_authorized_channel(
credentials, 'embeddedassistant.googleapis.com'
)
)

# Loop indefinitely
while True:
# Listen for voice input
with sr.Microphone() as source:
print("Listening...")
audio = r.listen(source)

# Convert the voice input to text


text = r.recognize

You might also like