[fusion_builder_container type=”flex” hundred_percent=”no” hundred_percent_height=”no” min_height=”” hundred_percent_height_scroll=”no” align_content=”stretch” flex_align_items=”flex-start” flex_justify_content=”flex-start” flex_column_spacing=”” hundred_percent_height_center_content=”yes” equal_height_columns=”no” container_tag=”div” menu_anchor=”” hide_on_mobile=”small-visibility,medium-visibility,large-visibility” status=”published” publish_date=”” class=”” id=”” link_color=”” link_hover_color=”” border_sizes=”” border_sizes_top=”” border_sizes_right=”” border_sizes_bottom=”” border_sizes_left=”” border_color=”” border_style=”solid” spacing_medium=”” margin_top_medium=”” margin_bottom_medium=”” spacing_small=”” margin_top_small=”” margin_bottom_small=”” margin_top=”” margin_bottom=”” padding_dimensions_medium=”” padding_top_medium=”” padding_right_medium=”” padding_bottom_medium=”” padding_left_medium=”” padding_dimensions_small=”” padding_top_small=”” padding_right_small=”” padding_bottom_small=”” padding_left_small=”” padding_top=”” padding_right=”” padding_bottom=”” padding_left=”” box_shadow=”no” box_shadow_vertical=”” box_shadow_horizontal=”” box_shadow_blur=”0″ box_shadow_spread=”0″ box_shadow_color=”” box_shadow_style=”” z_index=”” overflow=”” gradient_start_color=”” gradient_end_color=”” gradient_start_position=”0″ gradient_end_position=”100″ gradient_type=”linear” radial_direction=”center center” linear_angle=”180″ background_color=”” background_image=”” background_position=”center center” background_repeat=”no-repeat” fade=”no” background_parallax=”none” enable_mobile=”no” parallax_speed=”0.3″ background_blend_mode=”none” video_mp4=”” video_webm=”” video_ogv=”” video_url=”” video_aspect_ratio=”16:9″ video_loop=”yes” video_mute=”yes” video_preview_image=”” absolute=”off” absolute_devices=”small,medium,large” sticky=”off” sticky_devices=”small-visibility,medium-visibility,large-visibility” sticky_background_color=”” sticky_height=”” sticky_offset=”” sticky_transition_offset=”0″ scroll_offset=”0″ animation_type=”” animation_direction=”left” animation_speed=”0.3″ animation_offset=”” filter_hue=”0″ filter_saturation=”100″ filter_brightness=”100″ filter_contrast=”100″ filter_invert=”0″ filter_sepia=”0″ filter_opacity=”100″ filter_blur=”0″ filter_hue_hover=”0″ filter_saturation_hover=”100″ filter_brightness_hover=”100″ filter_contrast_hover=”100″ filter_invert_hover=”0″ filter_sepia_hover=”0″ filter_opacity_hover=”100″ filter_blur_hover=”0″][fusion_builder_row][fusion_builder_column type=”1_1″ align_self=”auto” content_layout=”column” align_content=”flex-start” content_wrap=”wrap” spacing=”” center_content=”no” link=”” target=”_self” min_height=”” hide_on_mobile=”small-visibility,medium-visibility,large-visibility” sticky_display=”normal,sticky” class=”” id=”” type_medium=”” type_small=”” type=”1_1″ order_medium=”0″ order_small=”0″ dimension_spacing_medium=”” dimension_spacing_small=”” dimension_spacing=”” dimension_margin_medium=”” dimension_margin_small=”” margin_top=”” margin_bottom=”” padding_medium=”” padding_small=”” padding_top=”” padding_right=”” padding_bottom=”” padding_left=”” hover_type=”none” border_sizes=”” border_color=”” border_style=”solid” border_radius=”” box_shadow=”no” dimension_box_shadow=”” box_shadow_blur=”0″ box_shadow_spread=”0″ box_shadow_color=”” box_shadow_style=”” background_type=”single” gradient_start_color=”” gradient_end_color=”” gradient_start_position=”0″ gradient_end_position=”100″ gradient_type=”linear” radial_direction=”center center” linear_angle=”180″ background_color=”” background_image=”” background_image_id=”” background_position=”left top” background_repeat=”no-repeat” background_blend_mode=”none” animation_type=”” animation_direction=”left” animation_speed=”0.3″ animation_offset=”” filter_type=”regular” filter_hue=”0″ filter_saturation=”100″ filter_brightness=”100″ filter_contrast=”100″ filter_invert=”0″ filter_sepia=”0″ filter_opacity=”100″ filter_blur=”0″ filter_hue_hover=”0″ filter_saturation_hover=”100″ filter_brightness_hover=”100″ filter_contrast_hover=”100″ filter_invert_hover=”0″ filter_sepia_hover=”0″ filter_opacity_hover=”100″ filter_blur_hover=”0″ last=”no” border_position=”all”][fusion_text columns=”” column_min_width=”” column_spacing=”” rule_style=”default” rule_size=”” rule_color=”” content_alignment_medium=”” content_alignment_small=”” content_alignment=”” hide_on_mobile=”small-visibility,medium-visibility,large-visibility” sticky_display=”normal,sticky” class=”” id=”” font_size=”” fusion_font_family_text_font=”” fusion_font_variant_text_font=”” line_height=”” letter_spacing=”” text_color=”” animation_type=”” animation_direction=”left” animation_speed=”0.3″ animation_offset=””]
- The SpeechRecognition library permits Python to access audio from your system’s mike, transcribe the audio, and reserve it.
- Google’s text-to-speech package, gTTS converts your audio inquiries to text.The response from the look-up perform that you simply write for attractive answer to the question is regenerate to an audio phrase by gTTS. This package interfaces with Google Translate’s API.
- Playsound package is employed to grant voice to the solution. Playsound permits Python to play MP3 files. Web browser package provides a high-level interface that permits displaying Web-based pages to users.
- Se is an alternative choice for displaying sites. However, for mistreatment this you would like to put in and supply the browser-specific net driver.
Implementation of the Personal Assistant
The entire code for this application is written in Python using libraries supported by Python.
Import required libraries:
[/fusion_text][fusion_code]aW1wb3J0IHNwZWVjaF9yZWNvZ25pdGlvbiBhcyBzciAjY29udmVydCBzcGVlY2ggdG8gdGV4dAppbXBvcnQgZGF0ZXRpbWUgI2ZvciBmZXRjaGluZyBkYXRlIGFuZCB0aW1lCmltcG9ydCB3aWtpcGVkaWEKaW1wb3J0IHdlYmJyb3dzZXIKaW1wb3J0IHJlcXVlc3RzCmltcG9ydCBwbGF5c291bmQgIyB0byBwbGF5IHNhdmVkIG1wMyBmaWxlIApmcm9tIGd0dHMgaW1wb3J0IGdUVFMgIyBnb29nbGUgdGV4dCB0byBzcGVlY2ggCmltcG9ydCBvcyAjIHRvIHNhdmUvb3BlbiBmaWxlcyAKaW1wb3J0IHdvbGZyYW1hbHBoYSAjIHRvIGNhbGN1bGF0ZSBzdHJpbmdzIGludG8gZm9ybXVsYQpmcm9tIHNlbGVuaXVtIGltcG9ydCB3ZWJkcml2ZXIgIyB0byBjb250cm9sIGJyb3dzZXIgb3BlcmF0aW9ucw==[/fusion_code][fusion_text columns=”” column_min_width=”” column_spacing=”” rule_style=”default” rule_size=”” rule_color=”” content_alignment_medium=”” content_alignment_small=”” content_alignment=”” hide_on_mobile=”small-visibility,medium-visibility,large-visibility” sticky_display=”normal,sticky” class=”” id=”” font_size=”” fusion_font_family_text_font=”” fusion_font_variant_text_font=”” line_height=”” letter_spacing=”” text_color=”” animation_type=”” animation_direction=”left” animation_speed=”0.3″ animation_offset=””]
Write a function to capture your requests/questions:
[/fusion_text][fusion_code]ZGVmIHRhbGsoKToKICAgIGlucHV0PXNyLlJlY29nbml6ZXIoKQogICAgd2l0aCBzci5NaWNyb3Bob25lKCkgYXMgc291cmNlOgogICAgICAgIGF1ZGlvPWlucHV0Lmxpc3Rlbihzb3VyY2UpCiAgICAgICAgZGF0YT0iIgogICAgICAgIHRyeToKICAgICAgICAgICAgZGF0YT1pbnB1dC5yZWNvZ25pemVfZ29vZ2xlKGF1ZGlvKQogICAgICAgICAgICBwcmludCgiWW91ciBxdWVzdGlvbiBpcywgIiArIGRhdGEpCiAgICAgICAgICAgIAogICAgICAgIGV4Y2VwdCBzci5Vbmtub3duVmFsdWVFcnJvcjoKICAgICAgICAgICAgcHJpbnQoIlNvcnJ5IEkgZGlkIG5vdCBoZWFyIHlvdXIgcXVlc3Rpb24sIFBsZWFzZSByZXBlYXQgYWdhaW4uIikKcmV0dXJuIGRhdGE=[/fusion_code][fusion_text columns=”” column_min_width=”” column_spacing=”” rule_style=”default” rule_size=”” rule_color=”” content_alignment_medium=”” content_alignment_small=”” content_alignment=”” hide_on_mobile=”small-visibility,medium-visibility,large-visibility” sticky_display=”normal,sticky” class=”” id=”” font_size=”” fusion_font_family_text_font=”” fusion_font_variant_text_font=”” line_height=”” letter_spacing=”” text_color=”” animation_type=”” animation_direction=”left” animation_speed=”0.3″ animation_offset=””]
Next, write a function to respond to your questions:
[/fusion_text][fusion_code]ZGVmIHJlc3BvbmQob3V0cHV0KToKICAgIG51bT0wCiAgICBwcmludChvdXRwdXQpCiAgICBudW0gKz0gMQogICAgcmVzcG9uc2U9Z1RUUyh0ZXh0PW91dHB1dCwgbGFuZz0nZW4nKQogICAgZmlsZSA9IHN0cihudW0pKyIubXAzIgogICAgcmVzcG9uc2Uuc2F2ZShmaWxlKQogICAgcGxheXNvdW5kLnBsYXlzb3VuZChmaWxlLCBUcnVlKQogICAgb3MucmVtb3ZlKGZpbGUp[/fusion_code][fusion_text columns=”” column_min_width=”” column_spacing=”” rule_style=”default” rule_size=”” rule_color=”” content_alignment_medium=”” content_alignment_small=”” content_alignment=”” hide_on_mobile=”small-visibility,medium-visibility,large-visibility” sticky_display=”normal,sticky” class=”” id=”” font_size=”” fusion_font_family_text_font=”” fusion_font_variant_text_font=”” line_height=”” letter_spacing=”” text_color=”” animation_type=”” animation_direction=”left” animation_speed=”0.3″ animation_offset=””]
Now write the module to add all the required customized responses to your questions:
[/fusion_text][fusion_code]aWYgX19uYW1lX189PSdfX21haW5fXyc6CiAgICByZXNwb25kKCJIaSwgSSBhbSBNaW5jaHUgeW91ciBwZXJzb25hbCBkZXNrdG9wIGFzc2lzdGFudCIpCiAgICAgICAgICAKICAgIHdoaWxlKDEpOgogICAgICAgIHJlc3BvbmQoIkhvdyBjYW4gSSBoZWxwIHlvdT8iKQogICAgICAgIHRleHQ9dGFsaygpLmxvd2VyKCkKICAgICAgICAKICAgICAgICBpZiB0ZXh0PT0wOgogICAgICAgICAgICBjb250aW51ZQogICAgICAgICAgICAKICAgICAgICBpZiAic3RvcCIgaW4gc3RyKHRleHQpIG9yICJleGl0IiBpbiBzdHIodGV4dCkgb3IgImJ5ZSIgaW4gc3RyKHRleHQpOgogICAgICAgICAgICByZXNwb25kKCJPayBieWUgYW5kIHRha2UgY2FyZSIpCiAgICAgICAgICAgIGJyZWFrCiAgICAgICAgICAgIAogICAgICAgIGlmICd3aWtpcGVkaWEnIGluIHRleHQ6CiAgICAgICAgICAgIHJlc3BvbmQoJ1NlYXJjaGluZyBXaWtpcGVkaWEnKQogICAgICAgICAgICB0ZXh0ID10ZXh0LnJlcGxhY2UoIndpa2lwZWRpYSIsICIiKQogICAgICAgICAgICByZXN1bHRzID0gd2lraXBlZGlhLnN1bW1hcnkodGV4dCwgc2VudGVuY2VzPTMpCiAgICAgICAgICAgIHJlc3BvbmQoIkFjY29yZGluZyB0byBXaWtpcGVkaWEiKQogICAgICAgICAgICBwcmludChyZXN1bHRzKQogICAgICAgICAgICByZXNwb25kKHJlc3VsdHMpCiAgICAgICAgICAgICAgICAgIAogICAgICAgIGVsaWYgJ3RpbWUnIGluIHRleHQ6CiAgICAgICAgICAgIHN0clRpbWU9ZGF0ZXRpbWUuZGF0ZXRpbWUubm93KCkuc3RyZnRpbWUoIiVIOiVNOiVTIikKICAgICAgICAgICAgcmVzcG9uZChmInRoZSB0aW1lIGlzIHtzdHJUaW1lfSIpICAgICAKICAgICAgICAKICAgICAgICBlbGlmICdzZWFyY2gnICBpbiB0ZXh0OgogICAgICAgICAgICB0ZXh0ID0gdGV4dC5yZXBsYWNlKCJzZWFyY2giLCAiIikKICAgICAgICAgICAgd2ViYnJvd3Nlci5vcGVuX25ld190YWIodGV4dCkKICAgICAgICAgICAgdGltZS5zbGVlcCg1KQogICAgICAgIAogICAgICAgIGVsaWYgImNhbGN1bGF0ZSIgb3IgIndoYXQgaXMiIGluIHRleHQ6IAogICAgICAgICAgICBxdWVzdGlvbj10YWxrKCkKICAgICAgICAgICAgYXBwX2lkPSJNZW50aW9uIHlvdXIgQVBJIEtleSIKICAgICAgICAgICAgY2xpZW50ID0gd29sZnJhbWFscGhhLkNsaWVudChhcHBfaWQpCiAgICAgICAgICAgIHJlcyA9IGNsaWVudC5xdWVyeShxdWVzdGlvbikKICAgICAgICAgICAgYW5zd2VyID0gbmV4dChyZXMucmVzdWx0cykudGV4dAogICAgICAgICAgICByZXNwb25kKCJUaGUgYW5zd2VyIGlzICIgKyBhbnN3ZXIpCiAgICAgICAgICAgIAogICAgICAgIGVsaWYgJ29wZW4gZ29vZ2xyJyBpbiB0ZXh0OgogICAgICAgICAgICB3ZWJicm93c2VyLm9wZW5fbmV3X3RhYigiaHR0cHM6Ly93d3cuZ29vZ2xlLmNvbSIpCiAgICAgICAgICAgIHJlc3BvbmQoIkdvb2dsZSBpcyBvcGVuIikKICAgICAgICAgICAgdGltZS5zbGVlcCg1KQogICAgICAgICAgICAKICAgICAgICBlbGlmICd5b3V0dWJlJyBpbiB0ZXh0OiAKICAgICAgICAgICAgZHJpdmVyID0gd2ViZHJpdmVyLkNocm9tZShyIk1lbnRpb24geW91ciB3ZWJkcml2ZXIgbG9jYXRpb24iKSAKICAgICAgICAgICAgZHJpdmVyLmltcGxpY2l0bHlfd2FpdCgxKSAKICAgICAgICAgICAgZHJpdmVyLm1heGltaXplX3dpbmRvdygpCiAgICAgICAgICAgIHJlc3BvbmQoIk9wZW5pbmcgaW4geW91dHViZSIpIAogICAgICAgICAgICBpbmR4ID0gdGV4dC5zcGxpdCgpLmluZGV4KCd5b3V0dWJlJykgCiAgICAgICAgICAgIHF1ZXJ5ID0gdGV4dC5zcGxpdCgpW2luZHggKyAxOl0gCiAgICAgICAgICAgIGRyaXZlci5nZXQoImh0dHA6Ly93d3cueW91dHViZS5jb20vcmVzdWx0cz9zZWFyY2hfcXVlcnkgPSIgKyAnKycuam9pbihxdWVyeSkpICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgIAogICAgICAgIGVsaWYgIm9wZW4gd29yZCIgaW4gdGV4dDogCiAgICAgICAgICAgIHJlc3BvbmQoIk9wZW5pbmcgTWljcm9zb2Z0IFdvcmQiKSAKICAgICAgICAgICAgb3Muc3RhcnRmaWxlKCdNZW50aW9uIGxvY2F0aW9uIG9mIFdvcmQgaW4geW91ciBzeXN0ZW0nKSAKICAgICAgICAKICAgICAgICBlbHNlOgogICAgICAgICAgIHJlc3BvbmQoIkFwcGxpY2F0aW9uIG5vdCBhdmFpbGFibGUiKQ==[/fusion_code][fusion_text columns=”” column_min_width=”” column_spacing=”” rule_style=”default” rule_size=”” rule_color=”” content_alignment_medium=”” content_alignment_small=”” content_alignment=”” hide_on_mobile=”small-visibility,medium-visibility,large-visibility” sticky_display=”normal,sticky” class=”” id=”” font_size=”” fusion_font_family_text_font=”” fusion_font_variant_text_font=”” line_height=”” letter_spacing=”” text_color=”” animation_type=”” animation_direction=”left” animation_speed=”0.3″ animation_offset=””]
Generate an executable for your voice assistant
[/fusion_text][fusion_code]cGlwIGluc3RhbGwgaXB5dGhvbgpwaXAgaW5zdGFsbCBuYmNvbnZlcnQKcGlwIGluc3RhbGwgcHlpbnN0YWxsZXI=[/fusion_code][fusion_code]aXB5dGhvbiBuYmNvbnZlcnQgLS10byBzY3JpcHQgbWluY2h1LmlweW5iICNtZW50aW9uIC5pcHluYiBmaWxlIG5hbWUgdG8gY29udmVydCB0byAucHk=[/fusion_code][fusion_code]cHlpbnN0YWxsZXIgbWluY2h1LnB5ICNidWlsZHMgLmV4ZSBmaWxl[/fusion_code][fusion_text columns=”” column_min_width=”” column_spacing=”” rule_style=”default” rule_size=”” rule_color=”” content_alignment_medium=”” content_alignment_small=”” content_alignment=”” hide_on_mobile=”small-visibility,medium-visibility,large-visibility” sticky_display=”normal,sticky” class=”” id=”” font_size=”” fusion_font_family_text_font=”” fusion_font_variant_text_font=”” line_height=”” letter_spacing=”” text_color=”” animation_type=”” animation_direction=”left” animation_speed=”0.3″ animation_offset=””]
Conclusion
[/fusion_text][/fusion_builder_column][/fusion_builder_row][/fusion_builder_container]