{"id":5028,"date":"2021-07-29T11:47:07","date_gmt":"2021-07-29T06:17:07","guid":{"rendered":"https:\/\/blog.guvi.in\/?p=5028"},"modified":"2026-05-29T12:50:26","modified_gmt":"2026-05-29T07:20:26","slug":"build-your-personal-voice-assistant","status":"publish","type":"post","link":"https:\/\/www.guvi.in\/blog\/build-your-personal-voice-assistant\/","title":{"rendered":"Build your own personal voice assistant like Siri, Alexa using Python in 2026"},"content":{"rendered":"\n<p>Have you ever looked at Siri or Alexa and thought, &#8220;I wish I could build something like that&#8221;? The good news is, you absolutely can. With just Python and a few free libraries, you can build your very own personal voice assistant that listens to your voice, talks back, searches the web, tells the weather, cracks jokes, and even sends emails for you.<\/p>\n\n\n\n<p>This tutorial is written for complete beginners. You do not need a computer science degree. You do not need to know machine learning. If you know basic Python, like what a function is and how a loop works, you are ready to follow along.<\/p>\n\n\n\n<p><strong>Quick Answer:<\/strong> To build a personal voice assistant using Python, install the SpeechRecognition and pyttsx3 libraries, set up a speech engine, write a listening function that uses Google&#8217;s audio API, and build commands for tasks like weather, Wikipedia search, and browser control. Follow this step-by-step guide to build your own working assistant from scratch.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>A Quick History: From IBM Shoebox to Smart Speakers<\/strong><\/h2>\n\n\n\n<p>Let us take two minutes to understand where voice assistants came from. It makes the whole thing feel a lot more exciting.<\/p>\n\n\n\n<p>Back in the early 1960s, IBM built a machine called the Shoebox. It could recognize 16 words and 9 digits spoken aloud. That was considered incredible at the time. In the 1990s, Dragon Systems released the first commercial speech software that could transcribe full sentences. That was the real turning point.<\/p>\n\n\n\n<p>Then in 2011, Apple launched Siri with the iPhone 4S, and suddenly millions of people were talking to their phones. Google Now and Microsoft Cortana followed. Amazon took it even further with Alexa and the Echo Dot, which gave birth to the smart speaker category we know today.<\/p>\n\n\n\n<p>Fast forward to 2026, and voice assistants have evolved massively. Apple has upgraded Siri with on-device AI. Google Assistant now runs on Gemini. Amazon Alexa supports third-party AI plugins. And with tools like OpenAI&#8217;s Whisper and GPT-4o available to developers, you can now build a voice assistant at home that is genuinely intelligent.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Where Personal Voice Assistants Stand in 2026<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Assistant<\/th><th>Company<\/th><th>Key Technology in 2026<\/th><\/tr><\/thead><tbody><tr><td>Siri<\/td><td>Apple<\/td><td>On-device LLM, Apple Intelligence<\/td><\/tr><tr><td>Google Assistant<\/td><td>Google<\/td><td>Gemini integration, contextual memory<\/td><\/tr><tr><td>Alexa<\/td><td>Amazon<\/td><td>Third-party LLM plugin support<\/td><\/tr><tr><td>Cortana<\/td><td>Microsoft<\/td><td>Merged into Microsoft 365 Copilot<\/td><\/tr><tr><td>JARVIS-One (yours!)<\/td><td>You<\/td><td>Python, SpeechRecognition, pyttsx3, OpenAI<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><img decoding=\"async\" width=\"828\" height=\"464\" src=\"http:\/\/blog.guvi.in\/wp-content\/uploads\/2021\/07\/Screenshot-2021-07-28-at-11.17.45-AM.png\" alt=\"Voice-Assistant \" class=\"wp-image-5031\" srcset=\"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2021\/07\/Screenshot-2021-07-28-at-11.17.45-AM.png 828w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2021\/07\/Screenshot-2021-07-28-at-11.17.45-AM-300x168.png 300w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2021\/07\/Screenshot-2021-07-28-at-11.17.45-AM-768x430.png 768w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2021\/07\/Screenshot-2021-07-28-at-11.17.45-AM-600x336.png 600w\" sizes=\"(max-width: 828px) 100vw, 828px\" title=\"\"><figcaption class=\"wp-element-caption\">MODERN ERA TRANSITIONS TO THE SMART SPEAKER REVOLUTION<\/figcaption><\/figure>\n\n\n\n<p><em>If you would like to explore Python programming through a Self-paced course, try HCL GUVI\u2019s <strong><a href=\"https:\/\/www.guvi.in\/courses\/programming\/python\/?utm_source=Blog&amp;utm_medium=hyperlink&amp;utm_campaign=Build+your+own+personal+voice+assistant+like+Siri%2C+Alexa+using+Python&amp;utm_term=Artificial+Intelligence\" data-type=\"link\" data-id=\"https:\/\/www.guvi.in\/courses\/programming\/python\/?utm_source=Blog&amp;utm_medium=organic&amp;utm_campaign=Build+your+own+personal+voice+assistant+like+Siri%2C+Alexa+using+Python&amp;utm_term=Artificial+Intelligence\" target=\"_blank\" rel=\"noreferrer noopener\">Python Course<\/a> with IIT Certification. <\/strong><\/em><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>What Will Your Personal Voice Assistant Be Able to Do?<\/strong><\/h2>\n\n\n\n<p>Before writing code, let us be clear about what we are building. Here is everything JARVIS-One, the voice assistant you will build in this tutorial, will be able to do:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Skill<\/th><th>What It Does<\/th><\/tr><\/thead><tbody><tr><td>Greet you<\/td><td>Says good morning, afternoon, or evening based on the time<\/td><\/tr><tr><td>Tell the time<\/td><td>Reads out the current time on command<\/td><\/tr><tr><td>Open YouTube, Google, Gmail<\/td><td>Launches websites in your browser<\/td><\/tr><tr><td>Search Wikipedia<\/td><td>Finds and reads a summary of any topic<\/td><\/tr><tr><td>Fetch the latest news<\/td><td>Opens Times of India headlines in your browser<\/td><\/tr><tr><td>Forecast the weather<\/td><td>Gets live weather for any city you name<\/td><\/tr><tr><td>Answer smart questions<\/td><td>Uses Wolfram Alpha to answer geography and math questions<\/td><\/tr><tr><td>Take a photo<\/td><td>Clicks a picture from your webcam<\/td><\/tr><tr><td>Tell a joke<\/td><td>Tells a random programming joke<\/td><\/tr><tr><td>Send an email<\/td><td>Composes and sends an email using your Gmail<\/td><\/tr><tr><td>Answer open-ended questions<\/td><td>Uses ChatGPT (GPT-4o) for anything it does not know<\/td><\/tr><tr><td>Shut down or log off<\/td><td>Signs you out of your PC on command<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><em>Pause here for a second: which of these 12 skills would save you the most time every day?<\/em><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span style=\"font-weight: 400;\"><strong>Let&#8217;s get started with Personal Voice-Assistant AI development&nbsp;<\/strong><\/span><\/h2>\n\n\n\n<p><span style=\"font-weight: 400;\">Let&#8217;s make a distinction here before we start. If you want to build voice and NLP capabilities into your own application, you have several cloud and API options. For Apple, you can use their Sirikit API, along with the $99 cost of registering yourself as an Apple developer and publishing on the Apple Store. One such example is Swiggy and its UI voice command to track the delivery partner. Other cloud options include Amazon&#8217;s Alexa with AWS account &amp; Google Now.&nbsp;<\/span><\/p>\n\n\n\n<p><span style=\"font-weight: 400;\">But in case you don&#8217;t wanna lock yourself in a particular ecosystem, you can develop your own system to enable voice-assistant. It&#8217;s just a matter of speech recognition, a pipeline, a rules engine, a query parser, and pluggable architecture with open APIs<\/span><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span style=\"font-weight: 400;\"><strong>The components &amp; Python Packages for Voice interface&nbsp;<\/strong><\/span><\/h2>\n\n\n\n<p><span style=\"font-weight: 400;\">Now we&#8217;d like to discuss the basic technologies in AI voice assistants. Simply put, what makes it different from a visual one, and characterize it as a voice interface.&nbsp;<\/span><\/p>\n\n\n\n<p><span style=\"font-weight: 400;\">There are few components of Voice assistant:&nbsp;<\/span><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><b>Voice Input\/output<\/b><\/h3>\n\n\n\n<p><b> <\/b><span style=\"font-weight: 400;\">It implies that the user does not need to touch their screen or GUI elements to make a request. Voice command is more than enough. Our voice assistant software will perform the given task using STT. They convert voice tasks given by the user into text scripts, analyze and perform them. We will be using <\/span><b>Speech recognition &amp; the pyttsx3<\/b><span style=\"font-weight: 400;\"> package library to convert speech to text and vice versa. The packages support Mac OS X, Linux, and Windows.&nbsp;<\/span><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><b>NLP &amp; Intelligent<\/b> <b>Interpretation<\/b><\/h3>\n\n\n\n<p><span style=\"font-weight: 400;\">Our voice assistant shouldn&#8217;t be limited to certain catchphrases, the user should be free while communicating. The response is made by tagging certain elements that can be credible for your user. We will be integrating <\/span><b>Wolfram Alpha API <\/b><span style=\"font-weight: 400;\">to compute expert-level answers using Wolfram&#8217;s knowledge base algorithms and AI technology. All made possible by Wolfram Language.&nbsp;<\/span><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><b>Subprocesses<\/b><\/h3>\n\n\n\n<p><b> <\/b><span style=\"font-weight: 400;\">This is a standard library from Python to process various system commands like to log off or restart, predict the current time, and set alarms. We will be using <\/span><b>OS<\/b><span style=\"font-weight: 400;\"> Library in python to enable the functions to interact with the operating system.&nbsp;<\/span><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><b>Compress the speech<\/b><\/h3>\n\n\n\n<p><span style=\"font-weight: 400;\">This feature of our voice assistant is responsible for the fast delivery of a command response to the user. We will use <\/span><b>JSON <\/b><span style=\"font-weight: 400;\">Module for storing and exchanging data. It&#8217;s reliable and fast.<\/span><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><b>Other libraries<\/b><\/h3>\n\n\n\n<p><span style=\"font-weight: 400;\">Apart from the essential features, we will use several other Python libraries such as <\/span><b>Wikipedia, Ecapture, Time, DateTime, request, and others <\/b><span style=\"font-weight: 400;\">to enable more functions.&nbsp;<\/span><\/p>\n\n\n\n<p><span style=\"font-weight: 400;\">To begin with, it&#8217;s necessary to install all the above-mentioned package libraries in your system using the <\/span><i><span style=\"font-weight: 400;\">pip command<\/span><\/i><span style=\"font-weight: 400;\">.&nbsp;<\/span>If you wanna clear your Python Fundamentals, visit here. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Writing script for Personal Voice Assistants <\/h2>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><img decoding=\"async\" width=\"1024\" height=\"640\" src=\"http:\/\/blog.guvi.in\/wp-content\/uploads\/2021\/07\/7806-1024x640.jpg\" alt=\"voice-assistant\" class=\"wp-image-5045\" srcset=\"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2021\/07\/7806-1024x640.jpg 1024w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2021\/07\/7806-300x188.jpg 300w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2021\/07\/7806-768x480.jpg 768w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2021\/07\/7806-1536x960.jpg 1536w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2021\/07\/7806-2048x1280.jpg 2048w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2021\/07\/7806-600x375.jpg 600w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2021\/07\/7806-945x591.jpg 945w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" title=\"\"><figcaption class=\"wp-element-caption\"> <\/figcaption><\/figure>\n\n\n\n<p>First of all, let&#8217;s import all the libraries using the pip command or terminal. For sake of clarity, we&#8217;ll name our personal voice assistant <strong>&#8220;JARVIS-One&#8221;<\/strong>. ( Any Resemblance is uncanny )<\/p>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code\">import speech_recognition as sr\nimport pyttsx3\nimport datetime\nimport os\nimport time\nimport subprocess\nimport wikipedia\nimport webbrowser\nfrom ecapture import ecapture as ec\nimport wolframalpha\nimport json\nimport requests<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Setting up Speech Engine <\/h3>\n\n\n\n<p>We are going to use <strong>Sapi5<\/strong>, a Microsoft text to speech engine for voice recognition. The Pyttsx3 module is stored in a variable name engine. We can set the voice id as either 0 or 1. &#8216;0&#8217; indicates male voice &amp; &#8216;1&#8217; indicates Female Voice. <\/p>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code\">engine=pyttsx3.init('sapi5')\nvoices=engine.getProperty('voices')\nengine.setProperty('voice','voices[0].id')<\/pre>\n\n\n\n<p>Further, we will define a function <strong>speak<\/strong> which will convert <a href=\"https:\/\/krispcall.com\/tools\/text-to-speech\/\" target=\"_blank\" data-type=\"link\" data-id=\"https:\/\/krispcall.com\/tools\/text-to-speech\/\" rel=\"noreferrer noopener\">text to speech<\/a>. The <strong>speak <\/strong> function will take the texts as an argument and it will further initialise the engine. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\">&#8216;<strong>RunAndWait&#8217;<\/strong> Command <\/h3>\n\n\n\n<p>Just as the name suggests, this function blocks other voice requests while processing all currently queued commands. It invokes callbacks for appropriate engine notification and returns back all the commands queued before the next call are emptied from the queue. <\/p>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code\">def speak(text):\n    engine.say(text)\n    engine.runAndWait()<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Greeting the User <\/h3>\n\n\n\n<p>The Python Library supports <strong>wishMe <\/strong>function for personal voice assistant to greet the user. The <strong>now().hour <\/strong> function abstract&#8217;s the hour from the current time. <\/p>\n\n\n\n<p id=\"100b\">If the hour is greater than zero and less than 12, the voice assistant wishes you with the message \u201cGood Morning &lt;F_name&gt;\u201d.<\/p>\n\n\n\n<p id=\"9f97\">If the hour is greater than 12 and less than 18, the voice assistant wishes you the following message \u201cGood Afternoon &lt;F_name&gt;\u201d.<\/p>\n\n\n\n<p id=\"c466\">Else it voices out the message \u201cGood evening\u201d<\/p>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code\">def wishMe():\n    hour=datetime.datetime.now().hour\n    if hour&gt;=0 and hour&lt;12:\n        speak(\"Hello F_name,Good Morning\")\n        print(\"Hello F_name,Good Morning\")\n    elif hour&gt;=12 and hour&lt;18:\n        speak(\"Hello F_name,Good Afternoon\")\n        print(\"Hello F_name,Good Afternoon\")\n    else:\n        speak(\"Hello F_name,Good Evening\")\n        print(\"Hello F_name,Good Evening\")<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Setting up command function for our personal voice assistant <\/h3>\n\n\n\n<p>Now we need to define a specific function <strong>takecommand <\/strong>for the personal voice assistant to understand, adapt and analyze the human language. The microphones capture the voice input and the recognizer recognizes the speech to give a response. <\/p>\n\n\n\n<p>We will also incorporate exception handling to rule out all exceptions during the run time error. The <strong>recognize_Google <\/strong>function uses google audio to recognize speech. <\/p>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code\">def takeCommand():\n    r=sr.Recognizer()\n    with sr.Microphone() as source:\n        print(\"Listening...\")\n        audio=r.listen(source)\n        try:\n            statement=r.recognize_google(audio,language='en-in')\n            print(f\"user said:{statement}\\n\")\n        except Exception as e:\n            speak(\"Pardon me, please say that again\")\n            return \"None\"\n        return statement\nprint(\"Loading your AI personal assistant JARVIS-One\")\nspeak(\"Loading your AI personal assistant JARVIS-One\")\nwishMe()<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">The Ongoing Function <\/h3>\n\n\n\n<p>The main function starts from here, the command given by the human interaction\/user is stored in the variable <strong>statement. <\/strong><\/p>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code\">if __name__=='__main__':\n    while True:\n        speak(\"How can I help you now?\")\n        statement = takeCommand().lower()\n        if statement==0:\n            continue<\/pre>\n\n\n\n<p>The voice assitant-JARVIS can now listen to some trigger words assigned by the user. <\/p>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code\">if \"good bye\" in statement or \"ok bye\" in statement or \"stop\" in statement:\n            speak('your personal assistant JARVIS-one is shutting down,Good bye')\n            print('your personal assistant JARVIS-one is shutting down,Good bye')\n            break<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Summoning Skills <\/h2>\n\n\n\n<p>Now that we have finished setting up the voice assistant, we will build the essential skills. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1. Accessing Data from Web Browsers-G-Mail, Google Chrome &amp; YouTube <\/h3>\n\n\n\n<p>The <strong>Open_new_tab <\/strong>function accepts web browser URL&#8217;s as a parameter that needs to be accessed. While <strong>Python time sleep function <\/strong>delays the execution of the program for a given time. <\/p>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code\">   elif 'open youtube' in statement:\n            webbrowser.open_new_tab(\"https:\/\/www.youtube.com\")\n            speak(\"youtube is open now\")\n            time.sleep(5)\n        elif 'open google' in statement:\n            webbrowser.open_new_tab(\"https:\/\/www.google.com\")\n            speak(\"Google chrome is open now\")\n            time.sleep(5)\n        elif 'open gmail' in statement:\n            webbrowser.open_new_tab(\"gmail.com\")\n            speak(\"Google Mail open now\")\n            time.sleep(5)<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">2. Fetching Data with Wikipedia API<\/h3>\n\n\n\n<p>Once we have successfully imported the Wikipedia API, we will use the following command to extract data from it. The <strong>wikipedia.summary() <\/strong>function helps users ask for any trivia, and execute it with a short summary as a <strong>variable result. <\/strong><\/p>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code\">if 'wikipedia' in statement:\n            speak('Searching Wikipedia...')\n            statement =statement.replace(\"wikipedia\", \"\")\n            results = wikipedia.summary(statement, sentences=3)\n            speak(\"According to Wikipedia\")\n            print(results)\n            speak(results)<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">3. Time Prediction <\/h3>\n\n\n\n<p><strong>JARVIS-one <\/strong>can predict the current time from <strong>datetime.now() <\/strong>function, which will display time in hour, minute &amp; second in a variable name <strong>strTime. <\/strong><\/p>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code\">        elif 'time' in statement:\n            strTime=datetime.datetime.now().strftime(\"%H:%M:%S\")\n            speak(f\"the time is {strTime}\")<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">4. Clicking Pictures <\/h3>\n\n\n\n<p>The <strong>ec.capture() <\/strong>function enables JARVIS-One click pictures from your camera. It has 3 parameters: Camera Index, Window Name &amp; Save Name. <\/p>\n\n\n\n<p>If there are two webcams, the first will has an indication with &#8216;0&#8217;, and the second will have an indication of &#8216;1&#8217;. Moreover, it can either be a string or a variable. In case you don&#8217;t wanna access this window, type as False. <\/p>\n\n\n\n<p>You can also give the name to the clicked image, if you don&#8217;t wish to save the image, type as <strong>False. <\/strong><\/p>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code\">  elif \"camera\" in statement or \"take a photo\" in statement:\n            ec.capture(0,\"robo camera\",\"img.jpg\")<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">5. To fetch latest news <\/h3>\n\n\n\n<p>JARVIS-One is programmed to fetch top headline news from Time of India by using the web browser function.<\/p>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code\">    elif 'news' in statement:\n            news = webbrowser.open_new_tab(\"https:\/\/timesofindia.indiatimes.com\/home\/headlines\u201d)\n            speak('Here are some headlines from the Times of India,Happy reading')\n            time.sleep(6)<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">6. Fetching Data from web <\/h3>\n\n\n\n<p>The <strong>open_new_tab() <\/strong>function will help search and extract data from a web browser. For instance, you can search for pictures of blue dandelions. <strong>Jarvis-One <\/strong>will help open google images and fetch them. <\/p>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code\">        elif 'search'  in statement:\n            statement = statement.replace(\"search\", \"\")\n            webbrowser.open_new_tab(statement)\n            time.sleep(5)<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">7. Wolfram Alpha API for geographical and computational questions <\/h3>\n\n\n\n<p>Third-party API Wolfram Alpha API enables Jarvis-one to answer computational and geographical questions. However, to access Wolfram alpha API, you need to create an account and have a unique app ID from their <a href=\"https:\/\/www.wolframalpha.com\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">official website<\/a>. The\u00a0<strong>client<\/strong>\u00a0is an instance (class) created for wolfram alpha whereas\u00a0<strong>res<\/strong>\u00a0variable stores the response given by the wolfram alpha.<\/p>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code\">lif 'ask' in statement:\n            speak('I can answer to computational and geographical questions  and what question do you want to ask now')\n            question=takeCommand()\n            app_id=\"Paste your unique ID here \"\n            client = wolframalpha.Client('R2K75H-7ELALHR35X')\n            res = client.query(question)\n            answer = next(res.results).text\n            speak(answer)\n            print(answer)<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">8. Weather Forecasting<\/h3>\n\n\n\n<p>With an API key from Open Weather Map, your personal voice assistant can detect weather. It is an online service that offers weather data for all locations. We can use <strong>city_name_variables <\/strong>command using <strong>takecommand() function. <\/strong>Here is the following code. <\/p>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code\">        elif \"weather\" in statement:\n            api_key=\"Apply your unique ID\"\n            base_url=\"https:\/\/api.openweathermap.org\/data\/2.5\/weather?\"\n            speak(\"what is the city name\")\n            city_name=takeCommand()\n            complete_url=base_url+\"appid=\"+api_key+\"&amp;q=\"+city_name\n            response = requests.get(complete_url)\n            x=response.json()\n            if x[\"cod\"]!=\"404\":\n                y=x[\"main\"]\n                current_temperature = y[\"temp\"]\n                current_humidiy = y[\"humidity\"]\n                z = x[\"weather\"]\n                weather_description = z[0][\"description\"]\n                speak(\" Temperature in kelvin unit is \" +\n                      str(current_temperature) +\n                      \"\\n humidity in percentage is \" +\n                      str(current_humidiy) +\n                      \"\\n description  \" +\n                      str(weather_description))\n                print(\" Temperature in kelvin unit = \" +\n                      str(current_temperature) +\n                      \"\\n humidity (in percentage) = \" +\n                      str(current_humidiy) +\n                      \"\\n description = \" +\n                      str(weather_description))\nview rawVoice_assistant.py hosted with \u2764 by GitHub<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">9. Credits <\/h3>\n\n\n\n<p>It will add an element of fun to program <strong>Jarvis_ONE <\/strong> to answer the questions such as &#8220;what it can do&#8221; and &#8220;who created it&#8221;. <\/p>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code\">       elif 'who are you' in statement or 'what can you do' in statement:\n            speak('I am JARVIS-one version 1 point O your personal assistant. I am programmed to minor tasks like'\n                  'opening youtube,google chrome, gmail and stackoverflow ,predict time,take a photo,search wikipedia,predict weather' \n                  'In different cities, get top headline news from times of india and you can ask me computational or geographical questions too!')\n        elif \"who made you\" in statement or \"who created you\" in statement or \"who discovered you\" in statement:\n            speak(\"I was built by F_NAME\")\n            print(\"I was built by F_NAME\")<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">10. Subprcesses-Log Off Your System <\/h3>\n\n\n\n<p>The&nbsp;<strong>subprocess.call()<\/strong>&nbsp;function here is used to process the system function to log off or to turn off your PC. Further, it invokes your AI assistant to automatically turn off your PC.<\/p>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code\">        elif \"log off\" in statement or \"sign out\" in statement:\n            speak(\"Ok , your pc will log off in 10 sec make sure you exit from all applications\")\n            subprocess.call([\"shutdown\", \"\/l\"])\n\t\t\t\ntime.sleep(3)<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">11. Telling a Joke <\/h3>\n\n\n\n<p>The <strong>pyjokes<\/strong> library returns a random programming joke on demand. Say &#8220;tell me a joke&#8221; and JARVIS-One picks one and reads it out:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>elif 'joke' in statement:\n&nbsp;&nbsp;&nbsp;&nbsp;joke = pyjokes.get_joke()\n&nbsp;&nbsp;&nbsp;&nbsp;speak(joke)\n&nbsp;&nbsp;&nbsp;&nbsp;print(joke)<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">12. Sending an Email <\/h3>\n\n\n\n<p>JARVIS-One can compose and send emails on your behalf using Python&#8217;s built-in smtplib. You need a Gmail App Password for this, not your regular password. Go to your Google Account, click Security, and generate an App Password from there:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>elif 'email' in statement or 'send mail' in statement:\n&nbsp;&nbsp;&nbsp;&nbsp;speak(\"Who should I send the email to?\")\n&nbsp;&nbsp;&nbsp;&nbsp;recipient = takeCommand()\n&nbsp;&nbsp;&nbsp;&nbsp;speak(\"What is the subject?\")\n&nbsp;&nbsp;&nbsp;&nbsp;subject = takeCommand()\n&nbsp;&nbsp;&nbsp;&nbsp;speak(\"What should I say in the email?\")\n&nbsp;&nbsp;&nbsp;&nbsp;body = takeCommand()\n&nbsp;&nbsp;&nbsp;&nbsp;try:\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;server = smtplib.SMTP('smtp.gmail.com', 587)\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;server.ehlo()\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;server.starttls()\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;server.login(\"your_email@gmail.com\", \"your_app_password\")\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;message = f\"Subject: {subject}\\n\\n{body}\"\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;server.sendmail(\"your_email@gmail.com\", recipient, message)\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;server.close()\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;speak(\"Email sent successfully.\")\n&nbsp;&nbsp;&nbsp;&nbsp;except Exception as e:\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;speak(\"Sorry, I was unable to send the email. Please check your credentials.\")<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">13. Upgrading JARVIS-One with ChatGPT (New)<\/h3>\n\n\n\n<p>This upgrade makes JARVIS-One handle any open-ended question intelligently using GPT-4o. Sign up at platform.openai.com and get your API key, then install the library: <em><strong>pip install openai<\/strong><\/em><\/p>\n\n\n\n<p>Add these lines near the top of your file after your other imports:<\/p>\n\n\n\n<p><em><strong>import openai<\/strong><\/em> <em><strong>openai.api_key = &#8220;YOUR_OPENAI_API_KEY&#8221;<\/strong><\/em><\/p>\n\n\n\n<p>Add this function above your main loop:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>def ask_chatgpt(question):\n&nbsp;&nbsp;&nbsp;&nbsp;response = openai.chat.completions.create(\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;model=\"gpt-4o\",\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;messages=&#91;{\"role\": \"user\", \"content\": question}]\n&nbsp;&nbsp;&nbsp;&nbsp;)\n&nbsp;&nbsp;&nbsp;&nbsp;return response.choices&#91;0].message.content<\/code><\/pre>\n\n\n\n<p>Add this as the very last block inside your <em><strong>while True<\/strong><\/em> loop, after all other <em><strong>elif<\/strong><\/em> blocks. This sends any unrecognized command straight to ChatGPT:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>else:\n&nbsp;&nbsp;&nbsp;&nbsp;response = ask_chatgpt(statement)\n&nbsp;&nbsp;&nbsp;&nbsp;speak(response)\n&nbsp;&nbsp;&nbsp;&nbsp;print(response)<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Quick Reference: All Voice Commands<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>What You Say<\/th><th>What JARVIS-One Does<\/th><\/tr><\/thead><tbody><tr><td>&#8220;What is the time&#8221;<\/td><td>Reads the current time<\/td><\/tr><tr><td>&#8220;Open YouTube&#8221;<\/td><td>Opens YouTube in your browser<\/td><\/tr><tr><td>&#8220;Open Google&#8221;<\/td><td>Opens Google in your browser<\/td><\/tr><tr><td>&#8220;Open Gmail&#8221;<\/td><td>Opens Gmail in your browser<\/td><\/tr><tr><td>&#8220;Search Wikipedia for [topic]&#8221;<\/td><td>Reads a Wikipedia summary<\/td><\/tr><tr><td>&#8220;News&#8221;<\/td><td>Opens Times of India headlines<\/td><\/tr><tr><td>&#8220;Weather&#8221;<\/td><td>Asks for a city and reads the forecast<\/td><\/tr><tr><td>&#8220;Ask&#8221;<\/td><td>Opens a Wolfram Alpha question<\/td><\/tr><tr><td>&#8220;Take a photo&#8221;<\/td><td>Captures a webcam photo<\/td><\/tr><tr><td>&#8220;Tell me a joke&#8221;<\/td><td>Reads a random programming joke<\/td><\/tr><tr><td>&#8220;Send mail&#8221;<\/td><td>Walks you through sending an email<\/td><\/tr><tr><td>&#8220;Who are you&#8221;<\/td><td>Assistant introduces itself<\/td><\/tr><tr><td>&#8220;Log off&#8221;<\/td><td>Logs off your PC<\/td><\/tr><tr><td>&#8220;Good bye&#8221; or &#8220;Stop&#8221;<\/td><td>Shuts down JARVIS-One<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Common Errors and How to Fix Them<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Error<\/th><th>What It Means<\/th><th>How to Fix It<\/th><\/tr><\/thead><tbody><tr><td>PyAudio install fails on Windows<\/td><td>Missing compiler dependency<\/td><td>Run pip install pipwin then pipwin install pyaudio<\/td><\/tr><tr><td>PyAudio install fails on Mac<\/td><td>PortAudio not installed<\/td><td>Run brew install portaudio first<\/td><\/tr><tr><td>&#8220;No module named speech_recognition&#8221;<\/td><td>Library not installed<\/td><td>Run pip install SpeechRecognition<\/td><\/tr><tr><td>Assistant does not respond to voice<\/td><td>Google Audio needs internet<\/td><td>Check your internet connection<\/td><\/tr><tr><td>Microphone not detected<\/td><td>Wrong default device<\/td><td>Set your mic as the default input in system sound settings<\/td><\/tr><tr><td>pyttsx3 is silent on Linux<\/td><td>espeak not installed<\/td><td>Run sudo apt install espeak in terminal<\/td><\/tr><tr><td>Wolfram returns no result<\/td><td>Query outside Wolfram&#8217;s scope<\/td><td>Wrap next(res.results) in a try\/except block<\/td><\/tr><tr><td>ecapture not working<\/td><td>OpenCV conflict<\/td><td>Replace with import cv2 and cv2.VideoCapture(0)<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Tips to Make JARVIS-One Better<\/h2>\n\n\n\n<ul>\n<li><strong>Use a USB microphone<\/strong> for dramatically better recognition accuracy compared to a built-in laptop mic.<\/li>\n\n\n\n<li><strong>Add noise cancellation<\/strong> by calling <em><strong>r.adjust_for_ambient_noise(source)<\/strong><\/em> right before <em><strong>r.listen(source)<\/strong><\/em> inside your takeCommand function.<\/li>\n\n\n\n<li><strong>Use a virtual environment<\/strong> by running <em><strong>python -m venv jarvis_env<\/strong><\/em> before installing packages to keep your dependencies clean.<\/li>\n\n\n\n<li><strong>Test each skill one at a time<\/strong> before running the full script so you can isolate issues faster.<\/li>\n\n\n\n<li><strong>Never use your regular Gmail password<\/strong> for the email skill. Always generate a Google App Password from your account&#8217;s security settings.<\/li>\n\n\n\n<li><strong>Add a wake word<\/strong> using the free Picovoice Porcupine library so JARVIS-One only activates when triggered, just like &#8220;Hey Siri.&#8221;<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">What You Can Build Next<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Extension Idea<\/th><th>Library to Use<\/th><th>What It Adds<\/th><\/tr><\/thead><tbody><tr><td>Add a visual interface<\/td><td>Tkinter or PyQt5<\/td><td>A window showing what the assistant hears and says<\/td><\/tr><tr><td>Control Spotify<\/td><td>Spotipy<\/td><td>Play, pause, and skip songs with your voice<\/td><\/tr><tr><td>Read your Google Calendar<\/td><td>gcsa<\/td><td>Hear your schedule and add new events by voice<\/td><\/tr><tr><td>Control smart home devices<\/td><td>Home Assistant API<\/td><td>Turn lights and fans on or off by voice<\/td><\/tr><tr><td>Add face recognition<\/td><td>face_recognition + OpenCV<\/td><td>Assistant identifies who is speaking<\/td><\/tr><tr><td>Deploy on Raspberry Pi<\/td><td>No extra library<\/td><td>A standalone always-on voice device<\/td><\/tr><tr><td>Make it multilingual<\/td><td>Google Translate API<\/td><td>Respond in Hindi, Tamil, or any language<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<div style=\"background-color: #099f4e; border: 3px solid #110053; border-radius: 12px; padding: 18px 22px; color: #FFFFFF; font-size: 18px; font-family: Montserrat, Helvetica, sans-serif; line-height: 1.6; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); max-width: 750px; margin: 22px auto;\">\n  <h3 style=\"margin-top: 0; font-size: 22px; font-weight: 700; color: #ffffff;\">\ud83d\udca1 Did You Know?<\/h3>\n  <ul style=\"padding-left: 20px; margin: 10px 0;\">\n    <li>Amazon Alexa supports over 100,000 third-party skills as of 2026, showing how voice assistant technologies power real-world commercial products.<\/li>\n    <li>Python\u2019s pyttsx3 library works completely offline, allowing voice assistants to speak even without an internet connection.<\/li>\n    <li>The global voice assistant market was valued at over USD 11 billion in 2025 and is projected to exceed USD 47 billion by 2033.<\/li>\n    <li>OpenAI\u2019s Whisper remains one of the most accurate open-source speech recognition models in 2026 and was trained on 680,000 hours of multilingual audio data.<\/li>\n  <\/ul>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Wrapping up <\/h2>\n\n\n\n<p>Now that you have got the hang of it, you can build your own personal voice assistant from scratch. Similarly, you can incorporate so many other free APIs available to enable more functionalities. <\/p>\n\n\n\n<p>In case you want to realign your code, visit this <a href=\"https:\/\/github.com\/mmirthula02\/AI-Personal-Voice-assistant-using-Python\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Git Repository.<\/a> (All credit goes to the developer). <em>HCL<\/em> GUVI is an IIT-M incubated springboard for knowledge and has helped millions of students with their programming journey. <\/p>\n\n\n\n<p><em>If you would like to explore Python programming through a Self-paced course, try <em>HCL<\/em><\/em> <em>GUVI\u2019s <strong><a href=\"https:\/\/www.guvi.in\/courses\/programming\/python\/?utm_source=Blog&amp;utm_medium=hyperlink&amp;utm_campaign=Build+your+own+personal+voice+assistant+like+Siri%2C+Alexa+using+Python&amp;utm_term=Artificial+Intelligence\" data-type=\"link\" data-id=\"https:\/\/www.guvi.in\/courses\/programming\/python\/?utm_source=Blog&amp;utm_medium=organic&amp;utm_campaign=Build+your+own+personal+voice+assistant+like+Siri%2C+Alexa+using+Python&amp;utm_term=Artificial+Intelligence\" target=\"_blank\" rel=\"noreferrer noopener\">Python Course<\/a> with IIT Certification. <\/strong><\/em><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>FAQs<\/strong><\/h2>\n\n\n<div id=\"rank-math-faq\" class=\"rank-math-block\">\n<div class=\"rank-math-list \">\n<div id=\"faq-question-1779257562381\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \">1. What Python libraries are needed to build a personal voice assistant?<\/h3>\n<div class=\"rank-math-answer \">\n\n<p>The core libraries are SpeechRecognition to capture your voice, pyttsx3 to convert text to speech, and PyAudio to access your microphone. For advanced skills, add wikipedia, wolframalpha, requests, pyjokes, smtplib, and openai.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1779257586297\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \">2. Can I build a Python voice assistant without an internet connection?<\/h3>\n<div class=\"rank-math-answer \">\n\n<p>Partially. The pyttsx3 speech engine works completely offline. However, Google Audio for speech recognition, OpenWeatherMap, Wolfram Alpha, and OpenAI all require an active internet connection.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1779257612999\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \">3. Is this Python voice assistant project suitable for absolute beginners?<\/h3>\n<div class=\"rank-math-answer \">\n\n<p>Yes. A basic understanding of Python functions and loops is enough to follow this tutorial. Every code block is explained before you write it.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1779257634587\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \">4. How do I add ChatGPT to my Python voice assistant?<\/h3>\n<div class=\"rank-math-answer \">\n\n<p>Install the openai library, set your API key, and define a function that calls <em><strong>openai.chat.completions.create()<\/strong><\/em>. Then add an <em><strong>else<\/strong><\/em> block at the end of your main loop to route unrecognized commands to GPT-4o.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1779257657205\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \">5. What is the difference between pyttsx3 and gTTS for text-to-speech in Python?<\/h3>\n<div class=\"rank-math-answer \">\n\n<p>pyttsx3 works offline and uses your system&#8217;s built-in voice engine so responses are instant. gTTS uses Google&#8217;s voice synthesis and sounds more natural but needs internet access and adds a small delay. For a beginner project, pyttsx3 is easier to set up.<\/p>\n\n<\/div>\n<\/div>\n<\/div>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>Have you ever looked at Siri or Alexa and thought, &#8220;I wish I could build something like that&#8221;? The good news is, you absolutely can. With just Python and a few free libraries, you can build your very own personal voice assistant that listens to your voice, talks back, searches the web, tells the weather, [&hellip;]<\/p>\n","protected":false},"author":65,"featured_media":5044,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[933],"tags":[],"views":"33039","authorinfo":{"name":"Jebasta","url":"https:\/\/www.guvi.in\/blog\/author\/jebasta\/"},"thumbnailURL":"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2021\/07\/Screenshot-2021-07-29-at-11.23.58-AM-300x168.png","_links":{"self":[{"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/posts\/5028"}],"collection":[{"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/users\/65"}],"replies":[{"embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/comments?post=5028"}],"version-history":[{"count":40,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/posts\/5028\/revisions"}],"predecessor-version":[{"id":112833,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/posts\/5028\/revisions\/112833"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/media\/5044"}],"wp:attachment":[{"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/media?parent=5028"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/categories?post=5028"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/tags?post=5028"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}