How to create Artificial Intelligence in Python : Part-4 || Iron Man Friday?



Hello Friends,

In this video i have implement the better Google search. Now, it will speak the result instead of just showing on browser.

Now, there is no need to download mp3 from AWS Polly services. You can just download and delete it from directory.

I hope you will find this video useful as previous ones.

Github : https://goo.gl/UM5m8D
Playlist : https://goo.gl/4sLjHp

If you have not subscribed the channel please hit the subscribe button and press the bell icon. You can connect…

Related Posts

32 Comments

  1. Bro, I'm getting this error:

    Traceback (most recent call last):

    File "D:/MARVEL/JARVIS_v3.py", line 119, in <module>

    google_search_result(voice_note)

    File "D:/MARVEL/JARVIS_v3.py", line 43, in google_search_result

    polly_sound(result.description.replace('…','').rsplit('.', 3)[0])

    File "D:/MARVEL/JARVIS_v3.py", line 31, in polly_sound

    with open(mp3_name, 'wb') as file:

    PermissionError: [Errno 13] Permission denied: 'output.mp3'

  2. sir please help with my problem, I get an error like this :

    "C:projek pythonjarvisvenvScriptspython.exe" "C:/projek python/jarvis/jarvis_v2.py"
    4 Okt 2017 – Planet Earth has an abundance of water that makes it unique and perfect for life to exist.

    Traceback (most recent call last):
    File "C:/projek python/jarvis/jarvis_v2.py", line 43, in <module>
    google_search_result('what is earth')

     File "C:/projek python/jarvis/jarvis_v2.py", line 41, in google_search_result
    play_sound_from_polly(result.description)

     File "C:/projek python/jarvis/jarvis_v2.py", line 29, in play_sound_from_polly
    obj = polly.synthesize_speech(Text=result, OutputFormat='mp3', VoiceId='Brian')

     File "C:projek pythonjarvisvenvlibsite-packagesbotocoreclient.py", line 357, in _api_call
    return self._make_api_call(operation_name, kwargs)

     File "C:projek pythonjarvisvenvlibsite-packagesbotocoreclient.py", line 661, in _make_api_call
    raise error_class(parsed_response, operation_name)

    botocore.exceptions.ClientError: An error occurred (UnrecognizedClientException) when calling the SynthesizeSpeech operation: The security token included in the request is invalid.

    Process finished with exit code 1

  3. Bro i have this error pls help me
    Missing required parameter in input: "OutputFormat"

    Unknown parameter in input: "OutputFromat", must be one of: Engine, LanguageCode, LexiconNames, OutputFormat, SampleRate, SpeechMarkTypes, Text, TextType, VoiceId

    pls…..????????????

  4. sir i got another error

    raise PlaysoundException(exceptionMessage)

    playsound.PlaysoundException:

    Error 263 for command:

    open "t" alias playsound_0.0691196174592

    The specified device is not open or is not recognized by MCI.

  5. sir i got this error
    botocore.exceptions.ClientError: An error occurred (InvalidSignatureException) when calling the SynthesizeSpeech operation: The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.

  6. polly = boto3.client('polly')

    counter = 0

    def play_sound_from_polly(result):

    global counter

    mp3_name = "output{}.mp3".format(counter)

    print(mp3_name)

    obj= polly.synthesize_speech(Text=result, OutputFormat='mp3', VoiceId='Joanna')

    print(type(obj))

    # to playsound with the help of playsound() we need to create mp3 file

    with open(mp3_name, 'wb') as f:

    f.write(obj['AudioStream'].read())

    f.close()

    playsound(mp3_name)

    os.remove(mp3_name)

    counter = counter + 1

    def google_search_result(query):

    search_result = google.search(query, lang='en')

    for result in search_result:

    print(result.description)

    play_sound_from_polly(result.description)

    break

    google_search_result("who is Narendra Modi")

    exit()

    After executing this code my mp3_name file is still empty

  7. why am i getting:
    Traceback (most recent call last):

    File "C:UsersUserDesktopsearch_directory.py", line 2, in <module>

    polly = boto3.client('polly')

    File "C:Python27libsite-packagesboto3__init__.py", line 79, in client

    return _get_default_session().client(*args, **kwargs)

    File "C:Python27libsite-packagesboto3session.py", line 192, in client

    aws_session_token=aws_session_token, config=config)

    File "C:Python27libsite-packagesbotocoresession.py", line 760, in create_client

    client_config=config, api_version=api_version)

    File "C:Python27libsite-packagesbotocoreclient.py", line 52, in create_client

    service_model = self._load_service_model(service_name, api_version)

    File "C:Python27libsite-packagesbotocoreclient.py", line 77, in _load_service_model

    api_version=api_version)

    File "C:Python27libsite-packagesbotocoreloaders.py", line 119, in _wrapper

    data = func(self, *args, **kwargs)

    File "C:Python27libsite-packagesbotocoreloaders.py", line 338, in load_service_model

    service_name, type_name)

    File "C:Python27libsite-packagesbotocoreloaders.py", line 119, in _wrapper

    data = func(self, *args, **kwargs)

    File "C:Python27libsite-packagesbotocoreloaders.py", line 280, in determine_latest_version

    return max(self.list_api_versions(service_name, type_name))

    File "C:Python27libsite-packagesbotocoreloaders.py", line 119, in _wrapper

    data = func(self, *args, **kwargs)

    File "C:Python27libsite-packagesbotocoreloaders.py", line 309, in list_api_versions

    raise DataNotFoundError(data_path=service_name)

    DataNotFoundError: Unable to load data for: polly

  8. To solve polly.client problem :

    import boto3

    polly_client = boto3.Session(

    aws_access_key_id=,

    aws_secret_access_key=,

    region_name='us-west-2').client('polly')

    response = polly_client.synthesize_speech(VoiceId='Joanna',

    OutputFormat='mp3',

    Text = 'This is a sample text to be synthesized.')

    file = open('speech.mp3', 'w')

    file.write(response['AudioStream'].read())

    file.close()

    and to get keys:

    create a free account on aws.amazone.com for 1 year then check your keys, free for one year.

  9. raceback (most recent call last):
    File "C:/Users/Yashi Agarwal/PycharmProjects/Yashinew/alexa21.py", line 136, in <module>
    google_search_result(voice_note)
    File "C:/Users/Yashi Agarwal/PycharmProjects/Yashinew/alexa21.py", line 47, in google_search_result
    play_sound_from_polly(result.description.replace('…','').rsplit('.', 3)[0])
    File "C:/Users/Yashi Agarwal/PycharmProjects/Yashinew/alexa21.py", line 31, in play_sound_from_polly
    obj = polly.synthesize_speech(Text=result, OutputFormat='mp3', VoiceId='Joannna')
    File "C:UsersYashi AgarwalPycharmProjectsYashinewvenvlibsite-packagesbotocoreclient.py", line 320, in _api_call
    return self._make_api_call(operation_name, kwargs)
    File "C:UsersYashi AgarwalPycharmProjectsYashinewvenvlibsite-packagesbotocoreclient.py", line 623, in _make_api_call
    raise error_class(parsed_response, operation_name)
    botocore.exceptions.ClientError: An error occurred (UnrecognizedClientException) when calling the SynthesizeSpeech operation: The security token included in the request is invalid.

    Process finished with exit code 1

  10. 1- Thanks for the video series
    2- How can I use another type of AWS service? because the AWS is free but I don't have credit card to register.

Leave a Reply

Your email address will not be published.

© 2022 Code As Pro - Theme by WPEnjoy · Powered by WordPress