python开发助理s

An AI personal assistant is a piece of software that understands verbal or written commands and completes task assigned by the client. It is an example of weak AI that is it can only execute and perform quest designed by the user.

AI个人助理是一种软件,可以理解口头或书面命令并完成客户端分配的任务。 这是弱AI的一个示例,它只能执行和执行用户设计的任务。

Want to build your own personal AI assistant like Apple Siri, Microsoft Cortana and Google assistant?

是否想建立自己的个人AI助手,例如Apple Siri,Microsoft Cortana和Google助手?

You can check out this blog to build one in a few simple steps!

您可以通过几个简单的步骤查看此博客以构建一个博客!

With the python programming language, a script most commonly used by the developers can be used to build your personal AI assistant to perform task designed by the users.

通过python编程语言,开发人员最常用的脚本可用于构建您的个人AI助手来执行用户设计的任务。

Now, let’s write a script for our personal voice assistant using python.

现在,让我们使用python为我们的个人语音助手编写脚本。

技能专长 (Skills:)

The implemented voice assistant can perform the following task it can open YouTube, Gmail, Google chrome and stack overflow. Predict current time, take a photo, search Wikipedia to abstract required data, predict weather in different cities, get top headline news from Times of India and can answer computational and geographical questions too.

已实现的语音助手可以执行以下任务,可以打开YouTube,Gmail,Google chrome和堆栈溢出。 预测当前时间,拍照,搜索Wikipedia以提取所需的数据,预测不同城市的天气,从《印度时报》获得头条新闻,还可以回答计算和地理问题。

The following queries of the voice assistant can be manipulated as per the users need.

语音助手的以下查询可以根据用户需要进行处理。

所需包装: (Packages required:)

To build a personal voice assistant it’s necessary to install the following packages in your system using the pip command.

要构建个人语音助手,必须使用pip命令在系统中安装以下软件包。

1) Speech recognition — Speech recognition is an important feature used in house automation and in artificial intelligence devices. The main function of this library is it tries to understand whatever the humans speak and converts the speech to text.

1) 语音识别 -语音识别是房屋自动化和人工智能设备中使用的重要功能。 该库的主要功能是尝试理解人类的讲话并将语音转换为文本。

2) pyttsx3 — pyttxs3 is a text to speech conversion library in python. This package supports text to speech engines on Mac os x, Windows and on Linux.

2) pyttsx3 — pyttxs3是python中的文本到语音转换库。 此软件包在Mac OS X,Windows和Linux上支持文本到语音引擎。

3) wikipedia — Wikipedia is a multilingual online encyclopedia used by many people from academic community ranging from freshmen to students to professors who wants to gain information over a particular topic. This package in python extracts data’s required from Wikipedia.

3) Wikipedia — Wikipedia是一种多语言的在线百科全书,许多学术界人士使用它,从新生,学生到想获取特定主题信息的教授。 python中的此软件包从Wikipedia中提取了所需的数据。

4) ecapture — This module is used to capture images from your camera

4) 捕获 —此模块用于捕获相机中的图像

5) datetime — This is an inbuilt module in python and it works on date and time

5) datetime —这是python中的内置模块,可按日期和时间运行

6) os — This module is a standard library in python and it provides the function to interact with operating system

6) os —该模块是python中的标准库,它提供与操作系统交互的功能

7) time — The time module helps us to display time

7) 时间 -时间模块可帮助我们显示时间

8) Web browser — This is an in-built package in python. It extracts data from the web

8) Web浏览器 -这是python中的内置软件包。 它从网上提取数据

9) Subprocess — This is a standard library use to process various system commands like to log off or to restart your PC.

9) 子进程 —这是一个标准库,用于处理各种系统命令,例如注销或重新启动PC。

10) Json- The json module is used for storing and exchanging data.

10) Json -json模块用于存储和交换数据。

11) request- The request module is used to send all types of HTTP request. Its accepts URL as parameters and gives access to the given URL’S.

11) request-请求模块用于发送所有类型的HTTP请求。 它接受URL作为参数,并允许访问给定的URL。

12) wolfram alpha — Wolfram Alpha is an API which can compute expert-level answers using Wolfram’s algorithms, knowledge base and AI technology. It is made possible by the Wolfram Language.

12) wolfram alpha — Wolfram Alpha是一种API,可以使用Wolfram的算法,知识库和AI技术来计算专家级答案。 Wolfram语言使之成为可能。

实现方式: (Implementation:)

Import the following libraries

导入以下库

设置语音引擎: (Setting up the speech engine:)

The pyttsx3 module is stored in a variable name engine.

pyttsx3模块存储在变量名引擎中。

Sapi5 is a Microsoft Text to speech engine used for voice recognition.

Sapi5是用于语音识别的Microsoft文本到语音引擎。

The voice Id can be set as either 0 or 1,

语音ID可以设置为0或1,

0 indicates Male voice

0表示男声

1 indicates Female voice

1表示女性声音

Now define a function speak which converts text to speech. The speak function takes the text as its argument,further initialize the engine.

现在定义一个功能speak ,它将文本转换为语音。 语音功能以文本为参数,进一步初始化引擎。

runAndWait: This function Blocks while processing all currently queued commands. It Invokes callbacks for engine notifications appropriately and returns back when all commands queued before this call are emptied from the queue.

runAndWait:此功能在处理所有当前排队的命令时阻塞。 它会适当地调用引擎通知的回调,并在从队列中清空此调用之前排队的所有命令时返回。

启动一个功能来迎接用户: (Initiate a function to greet the user:)

Define a function wishMe for the AI assistant to greet the user.

为AI助手定义一个功能wishMe来迎接用户。

The now().hour function abstract’s the hour from the current time.

now()。hour函数从当前时间开始抽象小时。

If the hour is greater than zero and less than 12, the voice assistant wishes you with the message “Good Morning”.

如果小时数大于零且小于12,则语音助手希望您收到消息“早安”。

If the hour is greater than 12 and less than 18, the voice assistant wishes you with the following message “Good Afternoon”.

如果小时数大于12且小于18,则语音助手希望您收到以下消息“下午好”。

Else it voices out the message “Good evening”

否则,它会发出“晚安”的信息

为您的AI助手设置命令功能: (Setting up the command function for your AI assistant :)

Define a function takecommand for the AI assistant to understand and to accept human language. The microphone captures the human speech and the recognizer recognizes the speech to give a response.

为AI助手定义一个功能接受命令 ,以理解和接受人类语言。 麦克风捕获人类语音,识别器识别语音以做出响应。

The exception handling is used to handle the exception during the run time error and,the recognize_google function uses google audio to recognize speech.

异常处理用于在运行时错误期间处理异常, identify_google函数使用google音频识别语音。

主要功能: (The Main function:)

The main function starts from here,the commands given by the humans is stored in the variable statement.

主要功能从这里开始,人类给出的命令存储在变量语句中

If the following trigger words are there in the statement given by the users it invokes the virtual assistant to speak the below following commands.

如果用户给出的语句中包含以下触发词,它将调用虚拟助手说出以下命令。

技能1-从Wikipedia获取数据: (Skill 1 -Fetching data from Wikipedia:)

The following commands helps to extract information from wikipedia. The wikipedia.summary() function takes two arguments, the statement given by the user and how many sentences from wikipedia is needed to be extracted is stored in a variable result.

以下命令有助于从Wikipedia中提取信息。 wikipedia.summary()函数采用两个参数,用户给出的语句以及需要从Wikipedia中提取多少个句子存储在变量结果中。

技能2-访问Web浏览器-Google chrome,G-Mail和YouTube: (Skill 2 -Accessing the Web Browsers — Google chrome , G-Mail and YouTube:)

The web browser extracts data from web. The open_new_tab function accepts URL as a parameter that needs to be accessed.

Web浏览器从Web提取数据。 open_new_tab函数接受URL作为需要访问的参数。

The Python time sleep function is used to add delay in the execution of a program. We can use this function to halt the execution of the program for given time in seconds.

Python时间睡眠功能用于增加程序执行的延迟。 我们可以使用此函数在给定的时间(以秒为单位)中暂停程序的执行。

技能3-预测时间: (Skill 3 -Predicting time:)

The current time is abstracted from datetime.now() function which displays the hour, minute and second and is stored in a variable name strTime.

当前时间是从datetime.now()函数中抽象出来的,该函数显示时,分和秒,并存储在变量名strTime中。

技能4-获取最新消息: (Skill 4 -To fetch latest news:)

If the user wants to know the latest news , The voice assistant is programmed to fetch top headline news from Time of India by using the web browser function.

如果用户想知道最新消息,则可以对语音助手进行编程,以使用网络浏览器功能从《印度时间》中获取头条新闻。

技能5-拍摄照片: (Skill 5 -Capturing photo:)

The ec.capture() function is used to capture images from your camera. It accepts 3 parameter.

ec.capture()函数用于从相机捕获图像。 它接受3个参数。

Camera index — The first connected webcam will be indicated as index 0 and the next webcam will be indicated as index 1

摄像机索引 —第一个连接的网络摄像机将显示为索引0,下一个网络摄像机将显示为索引1

Window name — It can be a variable or a string. If you don’t wish to see the window, type as False

窗口名称 -可以是变量或字符串。 如果您不希望看到该窗口,请输入False

Save name — A name can be given to the image and if you don’t want to save the image, type as false

保存名称 -可以为图像指定名称,如果您不想保存图像,请输入false

技能6-从网络搜索数据: (Skill 6-Searching data from web:)

From the web browser you can search required data by passing the user statement (command) to the open_new_tab() function.

Web浏览器中,您可以通过将用户语句(命令)传递给open_new_tab()函数来搜索所需的数据。

User: Hey G-One, please search images of butterfly

用户嗨,G-One,请搜索蝴蝶的图片

The Voice assistant opens the google window & fetches butterfly images from web.

语音助手会打开google窗口并从网络中获取蝴蝶图像。

技能7-设置AI助手回答地理和计算问题: (Skill 7- Setting your AI assistant to answer geographical and computational questions:)

Here we can use a third party API called Wolfram alpha API to answer computational and geographical questions.It is made possible by the Wolfram Language. The client is an instance (class) created for wolfram alpha. The res variable stores the response given by the wolfram alpha.

在这里,我们可以使用称为Wolfram alpha API的第三方API来回答计算和地理问题,这是由Wolfram语言实现的。 客户端是为Wolfram alpha创建的实例(类)。 res变量存储Wolfram alpha给出的响应。

To access the wolfram alpha API an unique App ID is required which can be generated by the following ways:

要访问wolfram alpha API,需要唯一的应用程序ID,可以通过以下方式生成:

  1. Login to the official page of wolfram alpha and create an account if you do not possess one.登录到Wolfram alpha的官方页面,并创建一个帐户(如果您没有该帐户)。
Image by author
图片作者

2. Sign in using your wolfram ID

2.使用您的Wolfram ID登录

Image by author
图片作者

3. Now you will view the homepage of the website. Head to the account section in the top right corner where you see your email. In the drop down menu, select the My Apps (API) option.

3.现在,您将查看网站的主页。 转到右上角的帐户部分,您会在其中看到您的电子邮件。 在下拉菜单中,选择我的应用程序(API)选项。

Image by author
图片作者

4. You will see this following window, now click Get APP_ID button

4.您将看到以下窗口,现在单击“获取APP_ID”按钮

Image by author
图片作者

5. Now you will get the following dialog box, give a suitable name and description and click the App ID button, an App ID will be generated and this is an unique ID. Using the App Id use can access the Wolfram alpha API.

5.现在,您将获得以下对话框,提供适当的名称和描述,然后单击“ App ID”按钮,将生成一个App ID,这是唯一的ID。 使用App ID可以访问Wolfram alpha API。

Image by author
图片作者

Human: Hey G-One ,what is the capital of California?

:嘿,G-One,加州的首都是什么?

G-One Voice assistant: Sacramento, United States of America

G-One语音助手: 美国萨克拉曼多

技能8-额外功能: (Skill 8- Extra features:)

It would be interesting to program your AI assistant to answer the following questions like what it can and who created it,isn't it?

对您的AI助手进行编程以回答以下问题,例如它可以做什么以及由谁创建,是不是很有趣?

技能9-预测天气: (Skill 9- To forecast weather:)

Now to program your AI assistant to detect weather we need to generate an API key from Open Weather map.

现在要对您的AI助手进行编程以检测天气,我们需要从“开放天气”地图中生成API密钥。

Open weather map is an online service which provides weather data. By generating an API ID in the official website you can use the APP_ID to make your voice assistant detect weather of all places whenever required. The necessary modules needed to be imported for this weather detection is json and request module.

开放式气象图是提供天气数据的在线服务。 通过在官方网站上生成API ID,您可以在需要时使用APP_ID使语音助手检测所有地方的天气。 为此天气检测需要导入的必要模块是json和request模块。

The city_name variable takes the command given by the human using the takeCommand() function.

city_name变量采用人类使用takeCommand()函数给出的命令。

The get method of request module returns a response object. And the json methods of response object converts json format data into python format.

请求模块的get方法返回一个响应对象。 响应对象的json方法将json格式的数据转换为python格式。

The variable X contains list of nested dictionaries which checks whether the value of ‘COD’ is 404 or not that is if the city is found or not.

变量X包含嵌套字典列表,该列表检查“ COD”的值是否为404,即是否找到城市。

The values such as temperature and humidity is stored in the main key of variable Y.

温度和湿度等值存储在变量Y的主键中。

Human: Hey G-One ,I want to get the weather data

人: 嘿,G-One,我想获取天气数据

G-One: What is the city name?

G-One: 城市名称是什么?

Human: Himachal Pradesh

人类: 喜马al尔邦

G-One: Temperature in kelvin unit is 301.09 , Humidity in percentage is 52 and Description is light rain.

G-One: 以开尔文为单位的温度为301.09,相对湿度为52,描述为小雨。

技能10-要注销PC: (Skill 10- To log off your PC:)

The subprocess.call() function here is used to process the system function to log off or to turn off your PC. This invokes your AI assistant to automatically turn off your PC.

这里的subprocess.call()函数用于处理系统功能以注销或关闭PC。 这将调用您的AI助手来自动关闭PC。

Hurray , We have finally built our own AI voice assistant . Further you can still add more functionalities to your AI voice assistant to perform more task.

华友世纪,我们终于建立了自己的AI语音助手。 此外,您仍然可以向AI语音助手添加更多功能以执行更多任务。

Image by author
图片作者

Check out my GitHub profile for code:

查看我的GitHub个人资料以获取代码:

https://github.com/mmirthula02/AI-Personal-Voice-assistant-using-Python

https://github.com/mmirthula02/AI-Personal-Voice-assistant-using-Python

Happy Coding !!

快乐编码!

翻译自: https://towardsdatascience.com/how-to-build-your-own-ai-personal-assistant-using-python-f57247b4494b

python开发助理s


http://www.taodudu.cc/news/show-1873994.html

相关文章:

  • 学习遗忘曲线_级联相关,被遗忘的学习架构
  • 她玩游戏好都不准我玩游戏了_我们可以玩游戏吗?
  • ai人工智能有哪些_进入AI有多么简单
  • 深度学习分类pytorch_立即学习AI:02 —使用PyTorch进行分类问题简介
  • 机器学习和ai哪个好_AI可以使您成为更好的运动员吗? 使用机器学习分析网球发球和罚球...
  • ocr tesseract_OCR引擎之战— Tesseract与Google Vision
  • 游戏行业数据类丛书_理论丛书:高维数据101
  • tesseract box_使用Qt Box Editor在自定义数据集上训练Tesseract
  • 人脸检测用什么模型_人脸检测模型:使用哪个以及为什么使用?
  • 不洗袜子的高文博_那个孩子在夏天中旬用高袜子大笑?
  • word2vec字向量_Anything2Vec:将Reddit映射到向量空间
  • ai人工智能伪原创_AI伪科学与科学种族主义
  • ai人工智能操控什么意思_为什么要建立AI分散式自治组织(AI DAO)
  • 机器学习cnn如何改变权值_五个机器学习悖论将改变您对数据的思考方式
  • DeepStyle(第2部分):时尚GAN
  • 肉体之爱的解释圣经_可解释的AI的解释
  • 机器学习 神经网络 神经元_神经网络如何学习?
  • 人工智能ai应用高管指南_理解人工智能指南
  • 机器学习 决策树 监督_监督机器学习-决策树分类器简介
  • ai人工智能数据处理分析_建立数据平台以实现分析和AI驱动的创新
  • 极限学习机和支持向量机_极限学习机的发展
  • 人工智能时代的危机_AI信任危机:如何前进
  • 不平衡数据集_我们的不平衡数据集
  • 建筑业建筑业大数据行业现状_建筑—第4部分
  • 线性分类模型和向量矩阵求导_自然语言处理中向量空间模型的矩阵设计
  • 离散数学期末复习概念_复习第1部分中的基本概念
  • 熵 机器学习_理解熵:机器学习的金标准
  • heroku_如何通过5个步骤在Heroku上部署机器学习UI
  • detr 历史解析代码_视觉/ DETR变压器
  • 人工神经网络方法学习步长_人工神经网络-一种直观的方法第1部分

python开发助理s_如何使用Python构建自己的AI个人助理相关推荐

  1. python开发是做什么的-python开发工程师是做什么的

    python开发工程师是指运用Python进行软件开发的工程师岗位. Python是一个高层次的结合了解释性.编译性.互动性和面向对象的脚本语言.Python 的设计具有很强的可读性,相比其他语言经常 ...

  2. [猿来小课]Python开发入门第三讲:Python的安装

    今天猿来小课的老师给想要学习python开发语言的同学们讲一讲Python的安装,手把手带着大家完成学习python开发第一步.有条件的小伙伴跟着我一起来实战操作吧. 猿来Python开发入门第三讲: ...

  3. python开发环境配置config_manjaro与python开发环境配置

    1.manjaro配置 1.1.启动项 sudo update-grub 注:Manjaro(archLinux)系统时间快8小时--> sudo timedatectl set-local-r ...

  4. python 开发api_使用FastAPI和Python快速开发高性能API

    python 开发api If you have read some of my previous Python articles, you know I'm a Flask fan. It is m ...

  5. python开发中级_针对中级Python开发人员的13个项目构想

    python开发中级 Learning the basics of Python is a wonderful experience. But the euphoria of just learnin ...

  6. python开发需要掌握哪些知识-Python后端开发如何入门,要学习那些系统性的知识?...

    Python本身就属于后端语言,学习知识如下: 第一部分:各个领域应用的语言. /> 大家看这个内容,其实你很明显发现,其实各个语言都有他的用处.我们可以说Python是应用最广的.但是暂时还是 ...

  7. python开发安卓程序-如何使用python开发android应用

    Python是一种面向对象.解释型计算机程序设计语言,其源代码和解释器CPython遵循GPL(GNU General Public License)协议Python语法简洁清晰,特色之一是强制用空白 ...

  8. python开发安卓程序-如何使用python开发Android手机应用?

    在使用python开发android应用之前我们需要准备好环境,环境需要安装PythonForAndroid,然后开始编程,编程时打开eclipse, 创建一个新的android project &q ...

  9. python开发需要掌握哪些知识-Python基础进阶需要掌握哪些知识点?

    Python基础进阶需要掌握哪些知识点?Python将是每个程序员的标配,有编程基础再掌握Python语言对于日后的升职加薪更有利.Python语言简洁利于理解,语法上相对容易能够让开发者更专注于业务 ...

  10. 使用python用什么软件-python开发工具有哪些(初学python用什么软件)

    python开发工具有哪些 一.jupyternotebookIDE简介-五星推荐 jupyternotebook是python学习与开发的一款简介的IDE,是一款Web应用程序,便于创建和编写文档等 ...

最新文章

  1. android 自定义录像机,android-camera2 - 将自定义捕获请求构建器选项设置为使用Camera2 API捕获图像以使用OpenCV库进行摄像机校准 - 堆栈内存溢出...
  2. 网络拓扑系列 - 网络拓扑的“管理”元素
  3. 使用原生JS实现简单的ajax
  4. 数据对比国内外电影票房,国产剧差在哪?
  5. hdu 1068(二分图最大独立集)
  6. mongodb 性能测试_MongoDB性能测试
  7. 在服务器上搭建基于yolo3 与crnn 实现中文自然场景文字检测及识别,GPU版本
  8. mysql打开慢查询_MySQL 开启慢查询日志的方法
  9. PHP微信H5支付Demo
  10. Verp中外部控制的六种方式
  11. 绿色全要素生产率数据(2004-2017年)
  12. 麦吉尔大学的数学与计算机科学,麦吉尔大学数学与计算机科学本科.pdf
  13. 计算机主机的声音线是哪个好,电脑显示器连接线哪种接口好|VGA、HDMI视频接口选哪个好...
  14. 服务器的iso文件,裸金属服务器注册ISO文件
  15. 上周,裤衩都亏掉了...
  16. 闽南师范大学计算机科学学院副书记,CCF闽南师范大学学生分会完成换届
  17. 点击按钮变色,松开按钮恢复原来的颜色
  18. 如何选择网络任务才能够轻松赚钱?(快营通分享)
  19. 股票波段+趋势+主力动向 三合一指标公式(无未来函数)
  20. TennisWorld

热门文章

  1. 设计模式 六大法则
  2. MySQL如何使用索引 较为详细的分析和例子
  3. 微软向学生征集Windows 8发行版建议
  4. 所谓的三十之后无技术
  5. mysql 修改密码
  6. 2021-02-13
  7. 摄影构图如何脱离规则套路
  8. vs C++实现Socket通信、添加ws2_32.lib 动态链接库
  9. 传智播客Java常量进制转换数据类型
  10. 190410每日一句