Mayukh Renish
Mayukh Renish

Reputation: 1

voice to email not sending the password

python voice to email not working. Everything works just fine. It records and gives me my message output, but it doesn't send the password.

import speech_recognition as sr
import yagmail

recognizer=sr.Recognizer()

with sr.Microphone() as source:
 print('clearing background noises:')

 recognizer.adjust_for_ambient_noise(source,duration=1)
 print("waiting for your message...")

 recordedaudio = recognizer.listen(source)
 print('done recording...!')

 try:
  print('printing the message..')
  text=recognizer.recognize_google(recordedaudio,language='en,US')

  print('Your message:{}'.format(text))

 except Exception as ex:
  print(ex)

  #automate mails:

  reciever='[email protected]'
  message=text

  sender=yagmail.SMTP('[email protected]')
  sender.send(to=reciever,subject='this is an automated email written by manas using python',contents=message)

Upvotes: -1

Views: 36

Answers (1)

Dariyoush
Dariyoush

Reputation: 508

after you get your txt message you can send it like this, if you want to add the voice message itself you can attach that as well. Note: It is possible that google tries to block the app if the security does not meet their criteria.

import yagmail

# beforehand, you take your message text here...

try:
    password = 'yourpasshere'
    sender = '[email protected]'
    recv = '[email protected]'
    msg = 'Your message:{}'.format(text)
    #in case you want to attach a voice message
    attach = '/path_to_your_voice_mesage/test.mp3'

    #initializing the server connection
    yag = yagmail.SMTP(user=sender, password=password)
    #sending the email

    yag.send(to=recv, subject='voice', smtp_ssl=False,
                contents=msg, attachments=attach)
except:
    print("Error, email was not sent")
else:
    print('Email sent successfully :)')

Upvotes: 0

Related Questions