<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Mohammadreza Rostam on Medium]]></title>
        <description><![CDATA[Stories by Mohammadreza Rostam on Medium]]></description>
        <link>https://medium.com/@pooya-rostam?source=rss-198b42691c99------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*UhQpcBr19QH7YGieEMQ0ow.jpeg</url>
            <title>Stories by Mohammadreza Rostam on Medium</title>
            <link>https://medium.com/@pooya-rostam?source=rss-198b42691c99------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 13:56:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@pooya-rostam/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Implementing a lightweight transcription microservice with gRPC]]></title>
            <link>https://medium.com/picovoice/implementing-a-lightweight-transcription-microservice-with-grpc-edfcf750a084?source=rss-198b42691c99------2</link>
            <guid isPermaLink="false">https://medium.com/p/edfcf750a084</guid>
            <category><![CDATA[grpc]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[speech-recognition]]></category>
            <dc:creator><![CDATA[Mohammadreza Rostam]]></dc:creator>
            <pubDate>Fri, 29 Apr 2022 12:11:39 GMT</pubDate>
            <atom:updated>2023-03-30T19:13:33.680Z</atom:updated>
            <content:encoded><![CDATA[<p>Microservices have emerged as a trend in web application architecture, and there are some excellent motivations behind this tendency. Building your app as a set of microservices improves efficiency, portability, flexibility, and scalability. There are already a couple of fantastic articles on creating microservices using gRPC and Go (<a href="https://tutorialedge.net/golang/go-grpc-beginners-tutorial/">this</a> and <a href="https://medium.com/@amsokol.com/tutorial-how-to-develop-go-grpc-microservice-with-http-rest-endpoint-middleware-kubernetes-daebb36a97e9">this</a>). So instead, I would like to extend them here and focus on showing you how to create a lightweight speech-to-text (STT) microservice.</p><p>An ideal STT microservice should be snappy and small so that it can be created and destroyed on demand easily at a low cost. Picovoice recently released its offline Speech-To-Text engine, Leopard. It is fast and has a small memory footprint <a href="https://picovoice.ai/blog/speech-to-text-2-better-faster-stronger/">[Speech-to-Text 2.0]</a>. At the same time, its accuracy is comparable to the cloud-based services according to its <a href="https://picovoice.ai/docs/benchmark/stt/">open-source benchmark</a>. You only need to<a href="http://console.picovoice.ai/"> a Picovoice accoun</a>t for this project and use your <a href="https://picovoice.ai/pricing/">Free Plan</a> allowances. No credit card required.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/614/0*hMwM8h7_6Ri-I1ho" /><figcaption>Comparison of accuracy of Picovoice Speech-to-Text against leading cloud-based alternatives</figcaption></figure><p>To have a working gRPC microservice, three components are essential:</p><ol><li>A .proto file to define the gRPC services and messages</li><li>A server to process the submitted audio and returns back the transcription</li><li>A client to talk to the server</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e9P9CFYqyRtGqs61VFwipw.png" /></figure><p><strong>.proto file:</strong></p><p>Let’s start with defining the interface in proto format:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ca0566fa8cf9417cda7c174214b0a894/href">https://medium.com/media/ca0566fa8cf9417cda7c174214b0a894/href</a></iframe><p>To keep everything simple, only one service (GetTranscriptionFile) is defined in the proto file. Since gRPC limits incoming messages to 4 MB by default, the type of the transcription service needs to be set to the client-side stream. This way, files are sent to the server in chunks of bytes.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/14980d9482998e10d421c9add0694e9b/href">https://medium.com/media/14980d9482998e10d421c9add0694e9b/href</a></iframe><p>The transcriptResponse message, which is sent back to the client, contains both inferred transcription and status code to tell the caller whether the call was successful.</p><p>Before we can import and use this service method in other files, we need to compile the .proto file with protoc as we are going to write both server and client in Go.</p><p><strong>Client:</strong></p><p>On the client-side, we need first to make a connection to the server and then create a client for the defined LeopardService service.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a033507c3f46544edc37820041422a90/href">https://medium.com/media/a033507c3f46544edc37820041422a90/href</a></iframe><p>Inside the runsTranscriptFile function, the audio file is read in chunks of 1 MB and transmitted over to the server, and a timeout of 10 seconds is considered here. Finally, the stream is closed, and the server response is received by calling the CloseAndRecv function.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/de872359adc262beed7d9426d5a0c8f9/href">https://medium.com/media/de872359adc262beed7d9426d5a0c8f9/href</a></iframe><p><strong>Server:</strong></p><p>On the server-side, a gRPC service instance is defined and registered to answer to LeopardService calls.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cd757a8da17e10e7237838946ea91b8e/href">https://medium.com/media/cd757a8da17e10e7237838946ea91b8e/href</a></iframe><p>Once a transcription request is received, the server starts an instance of the Leopard engine and keeps reading the shipped bytes until the EOF is received. After that, the bytes are stored as a temporary file and then passed to the leopard engine. Finally, the transcription is sent back to the client side along with a status code.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c23c2da7cc62cbd7cd669b12fae7f8d2/href">https://medium.com/media/c23c2da7cc62cbd7cd669b12fae7f8d2/href</a></iframe><p>We could also have sent the audio in raw (pcm) format and directly fed it to the Leopard engine without storing it on the drive, but there are two caveats. First, more preprocessing work would have to be done on the client-side to decode the audio file. Second, the amount of data needed to be transferred for the raw format is significantly more than compressed formats like MP3 or OGG.</p><p>That’s all! Now you just need to run the server and client with proper input arguments.</p><p>The source code of this demo can be found on <a href="https://github.com/Picovoice/leopard/tree/master/demo/go-grpc">Leopard GitHub Repository</a>. It can serve as a template or a starting point and be tailored to meet individual requirements. For instance, if you want to transcribe an audio file that is already on the internet, you can modify the demo and send a simple URL to the server instead of the entire file. Please refer to the <a href="https://github.com/Picovoice/leopard/blob/master/demo/go-grpc/readme.md">readme.md</a> to run the demo and see it in practice. To know more about the Leopard Go APIs, take a look at <a href="https://picovoice.ai/docs/api/leopard-go/">Leopard Docs Page</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=edfcf750a084" width="1" height="1" alt=""><hr><p><a href="https://medium.com/picovoice/implementing-a-lightweight-transcription-microservice-with-grpc-edfcf750a084">Implementing a lightweight transcription microservice with gRPC</a> was originally published in <a href="https://medium.com/picovoice">Picovoice</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Offline Voice AI on Arduino]]></title>
            <link>https://medium.com/picovoice/offline-voice-ai-on-arduino-4a7f7e572bfb?source=rss-198b42691c99------2</link>
            <guid isPermaLink="false">https://medium.com/p/4a7f7e572bfb</guid>
            <dc:creator><![CDATA[Mohammadreza Rostam]]></dc:creator>
            <pubDate>Mon, 14 Jun 2021 21:39:05 GMT</pubDate>
            <atom:updated>2023-02-12T15:09:36.807Z</atom:updated>
            <content:encoded><![CDATA[<p>Did you know it’s now possible to perform high-accuracy speech recognition on a microcontroller? Advances in machine learning have brought voice capability to these extremely resource-constrained devices, via the Picovoice SDK. Arduino recently joined the list of supported devices, starting with the <a href="https://store.arduino.cc/usa/nano-33-ble-sense">Arduino Nano 33 BLE Sense</a>. We’re going to add a voice assistant loop to this board and demonstrate how you can easily customize it to make your Arduino understand naturally-spoken phrases of your own design.</p><p>The <a href="https://picovoice.ai/docs/picovoice/">Picovoice SDK</a> is able to infer a user’s intent from a naturally spoken utterance such as:</p><blockquote><em>“Picovoice, make the blue light blink ten times quickly.”</em></blockquote><p>Picovoice detects the wake word (“<strong>Picovoice”</strong>), then determines the intent from the follow-on spoken command (“make the blue lights blink ten times quickly”):</p><pre>{ <br> “intent”: “blinkLight”, <br> “slots”: {  <br>  “color”: “blue”<br>  “Iteration”: “10”<br>  “speed”: “quickly”<br> }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*IY56TXM6wmBj-Tgc" /><figcaption>Arduino Nano 33 BLE Sense</figcaption></figure><p>Let’s start with a demo project that controls the Arduino’s on-board LEDs, using voice commands.</p><p>I have shared the source code <a href="https://create.arduino.cc/editor/dynamix91/7dae06f6-b827-4b20-ad00-b1558ae1b98c/preview">here</a>, so you can try it yourself:</p><ol><li>Download the <a href="https://create.arduino.cc/editor/dynamix91/7dae06f6-b827-4b20-ad00-b1558ae1b98c/preview">project</a> (both Control_LED_Picovoice.in and param.h).</li><li>Open the<a href="https://www.arduino.cc/en/guide/libraries"> Library Manager</a> in the Arduino IDE, search for the Picovoice package, and click on the Install button.</li><li>Sign up for <a href="https://console.picovoice.ai/">Picovoice Console</a> to get your AccessKey for free. We will need an AccessKey to use the Picovoice package.</li><li>Open the downloaded sketch, and replace the placeholder with your AccessKey:</li></ol><pre>static const char* ACCESS_KEY = &quot;${YOUR_ACCESSKEY}&quot;; // AccessKey string obtained from Picovoice Console (https://picovoice.ai/console/)</pre><ol><li>Upload it into the board.</li><li>Open the serial monitor. You will see the grammar for the context, describing all of the follow-on voice commands it understands.</li><li>Say, for example:</li></ol><blockquote>“Picovoice, make red flash”</blockquote><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fb7wzFEDU0U8%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Db7wzFEDU0U8&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fb7wzFEDU0U8%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/62ac8f15c5e1804e9c568cdba5518805/href">https://medium.com/media/62ac8f15c5e1804e9c568cdba5518805/href</a></iframe><h3>Build your own Sketch</h3><p><strong>Create a custom context model</strong></p><p>Go to<a href="http://picovoice.ai/console/"> Picovoice Console</a>, an online tool for easily designing and training models for voice interactions that run on the Picovoice SDK. I suggest watching <a href="https://www.youtube.com/watch?v=npBaOx30QUs&amp;t=19s">this video tutorial</a> or reading <a href="https://picovoice.ai/docs/rhino/">this guide</a> if you want to learn more.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*E7iFXpD9JybQ0N2o" /><figcaption>Context Editor</figcaption></figure><p><strong>Add the context model to a project</strong></p><ol><li>Replace CONTEXT_ARRAY in the param.h file with the new context model by following the steps explained in the <a href="https://picovoice.ai/docs/quick-start/picovoice-arduino/">Picovoice SDK for Arduino documentation</a>.</li><li>Update the inference_callback so that it takes appropriate actions (e.g., blinking a LED) once an intent is recognized.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/0*SESIS4gbp8ptTWZM" /><figcaption>The logic inside the inference_callback function to address several intents with different slots.</figcaption></figure><p>Learn more about working with the Picovoice SDK for Arduino by visiting the <a href="https://picovoice.ai/docs/api/picovoice-microcontroller/">documentation</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a7f7e572bfb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/picovoice/offline-voice-ai-on-arduino-4a7f7e572bfb">Offline Voice AI on Arduino</a> was originally published in <a href="https://medium.com/picovoice">Picovoice</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Shush SSH, and Talk to Your Pi Instead]]></title>
            <link>https://medium.com/picovoice/shush-ssh-and-talk-to-your-pi-instead-7f8bcd382595?source=rss-198b42691c99------2</link>
            <guid isPermaLink="false">https://medium.com/p/7f8bcd382595</guid>
            <category><![CDATA[tinyml]]></category>
            <category><![CDATA[speech-recognition]]></category>
            <category><![CDATA[motion-detection]]></category>
            <category><![CDATA[raspberry-pi]]></category>
            <category><![CDATA[voice-assistant]]></category>
            <dc:creator><![CDATA[Mohammadreza Rostam]]></dc:creator>
            <pubDate>Tue, 04 May 2021 03:20:39 GMT</pubDate>
            <atom:updated>2022-09-13T21:43:40.391Z</atom:updated>
            <content:encoded><![CDATA[<p>I am a huge fan of Raspberry Pi DIY projects that have gone beyond being just “cool” and have practical applications. Among all these projects, I have found the “<a href="https://www.instructables.com/How-to-Build-a-Raspberry-Pi-Smart-Mirror/">smart mirror</a>” and “<a href="https://www.instructables.com/Raspberry-Pi-Motion-Detection-Security-Camera/">motion detection camera</a>” projects particularly useful.</p><p>One common issue with both these projects is that you need to ssh into your Pi, even for a single simple task such as switching a camera/screen on or off. It might be easy for some of us — even enjoyable, if you are like me and dig that terminal screen — but it is inconvenient, and provides a barrier of entry for non-technical people. I decided to replace SSH with a bespoke voice assistant. There are multiple voice recognition options for Raspberry Pi. However, most of them need internet connectivity, and using them raises privacy concerns: the device is always broadcasting your microphone data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SMZKYK_7YTbxkdA_jcz8Gw.png" /></figure><p><a href="https://picovoice.ai/">Picovoice AI</a> is a perfect match for these applications: it processes voice data offline and runs entirely on your Raspberry Pi. Processing on the edge eliminates connectivity, latency, and privacy issues completely. Picovoice has an extremely efficient engine that enables it to run on low-power microcontrollers, meaning you do not need to worry about overhead. This is especially important in the smart mirror use case if you are using a battery as the power source.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l3hw0thbxXN2UqZph9ZTrQ.jpeg" /></figure><p>To keep it short, I am only going to create and test a voice interface for the motion detection camera project. The integration will be done later in a follow-up article. The final voice interface will be able to understand commands for managing cameras, like:</p><blockquote>Computer, switch on the front door camera</blockquote><p>Picovoice supports all Raspberry Pi variants. The original motion detection camera project uses a Raspberry Pi 3, and I will be using the same. Regarding the microphone, I am using a small USB mic as I do not like extra wires coming out of my board.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6RMfRw_b-e-NRQEo3GNp4Q.jpeg" /></figure><p>In my experience, Linux is usually clever enough to recognize and configure most USB mics. However, if you have any difficulties, you can get the list of available input audio devices by running the following command inside your terminal:</p><pre>arecord -L | grep plughw</pre><p>The output should be similar to below:</p><pre>plughw:CARD=PCH,DEV=0</pre><p>Copy this line and create a .asoundrc file in your home folder with these options:</p><pre>pcm.!default {<br>   type asym<br>   capture.pcm &quot;mic&quot;<br>}<br>pcm.mic {<br>   type plug<br>   slave {<br>      pcm &quot;${INPUT_AUDIO_DEVICE}&quot;<br>   }<br>}</pre><p>Replace ${INPUT_AUDIO_DEVICE} with what you copied earlier. You may need to reboot the system for these settings to take effect.</p><p>After that, grab the Picovoice python package:</p><pre>sudo pip3 install picovoice picovoicedemo</pre><p>The picovoicedemo package let us test our models rapidly. The package requires a valid AccessKey. Signup or Login to <a href="https://console.picovoice.ai/">Picovoice Console</a> to get your AccessKey.</p><p>We are now ready to design our voice interface using<a href="http://picovoice.ai/console/"> Picovoice Console</a>.</p><p>For the motion detection project, I focused on three main command types:</p><ul><li>Turning cameras on/off.</li><li>Cleaning old files to make space for new pictures.</li><li>Emailing the log files.</li></ul><p>I created a simple context to capture the aforementioned commands utilizing a variety of different expressions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8jrBLrvJJ3NJQzVQoP1rQg.png" /></figure><p>In order to reproduce what I made, you can copy the YAML code below and import it into Picovoice Console using the Import YAML button:</p><pre>context:<br>  expressions:<br>    changeCameraState:<br>      - &quot;[switch, turn] $state:state (all, the) cameras&quot;<br>      - &quot;[switch, turn] (all, the) cameras $state:state&quot;<br>      - &quot;[switch, turn] $state:state (the) $location:location (camera, cameras)&quot;<br>      - &quot;[switch, turn] (the) $location:location [camera, cameras] $state:state&quot;<br>      - &quot;[switch, turn] $state:state (the) [light, lights] [at, in] (the)<br>        $location:location&quot;<br>      - &quot;[switch, turn] (the) [light, lights] [in, at] the $location:location<br>        $state:state&quot;<br>    cleanCameraHistory:<br>      - &quot;[delete, remove, clean] all (the) [files, videos] older than<br>        $pv.TwoDigitInteger:day [day, days]&quot;<br>      - &quot;[delete, remove, clean] all (the) [files, videos] older than<br>        $pv.TwoDigitInteger:month [month, months]&quot;<br>    emailLog:<br>      - &quot;[email, mail] (me) (all) the [log, logs]&quot;<br>      - &quot;[email, mail] (me) a report&quot;<br>  slots:<br>    state:<br>      - off<br>      - on<br>    location:<br>      - garage<br>      - entrance<br>      - front door<br>      - back door<br>      - driveway<br>      - yard<br>      - stairway<br>      - Hallway</pre><p>After training the model, download and extract it into your home folder. I picked “Computer” as the wake-word from the free wake-words available on<a href="https://github.com/Picovoice/porcupine/tree/6d86f507f5068760bfa81361bac26b26563db56f/resources/keyword_files/raspberry-pi"> GitHub</a>.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F7hQ2fFz6MYQ&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D7hQ2fFz6MYQ&amp;image=http%3A%2F%2Fi.ytimg.com%2Fvi%2F7hQ2fFz6MYQ%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/5e9155dfd0462a11de0234e3ded17667/href">https://medium.com/media/5e9155dfd0462a11de0234e3ded17667/href</a></iframe><p>The next step is integrating the voice interface into the existing motion camera detection project. Picovoice eases this step by offering a Python SDK. We need to only modify the wake_word_callback and inference_callback functions based on the context model’s intents:</p><pre>from picovoice import Picovoice<br> <br>keyword_path = ...<br> <br>def wake_word_callback():<br>    # wake word detected<br>    pass</pre><pre>context_path = ...<br> <br>def inference_callback(inference):<br>    # `inference` exposes three immutable fields:<br>    # (1) `is_understood`<br>    # (2) `intent`<br>    # (3) `slots`<br>    pass<br> <br>handle = Picovoice(<br>        access_key=${ACCESS_KEY},<br>        keyword_path=keyword_path,<br>        wake_word_callback=wake_word_callback,<br>        context_path=context_path,<br>        inference_callback=inference_callback)<br>        <br>while True:<br>    handle.process(get_next_audio_frame())</pre><p>For more detailed information, please refer to the <a href="https://picovoice.ai/docs/api/picovoice-python/">Python API documentation</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7f8bcd382595" width="1" height="1" alt=""><hr><p><a href="https://medium.com/picovoice/shush-ssh-and-talk-to-your-pi-instead-7f8bcd382595">Shush SSH, and Talk to Your Pi Instead</a> was originally published in <a href="https://medium.com/picovoice">Picovoice</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[“Offline speech recognition for my self-driving toy car on Jetson Nano, please!”]]></title>
            <link>https://medium.com/picovoice/offline-speech-recognition-for-my-self-driving-toy-car-on-jetson-nano-please-bbd792afd929?source=rss-198b42691c99------2</link>
            <guid isPermaLink="false">https://medium.com/p/bbd792afd929</guid>
            <dc:creator><![CDATA[Mohammadreza Rostam]]></dc:creator>
            <pubDate>Tue, 16 Mar 2021 15:01:47 GMT</pubDate>
            <atom:updated>2022-09-13T21:58:04.064Z</atom:updated>
            <content:encoded><![CDATA[<p>Jetson Nano, the latest machine learning development platform from Nvidia, is emerging as a popular platform with exciting potential for Edge AI applications. The latest such application: on-device speech recognition and natural language understanding.</p><p>Picovoice recently added support for Jetson Nano. This means you can create and add a <a href="https://picovoice.ai/docs/glossary/#voice-user-interface-vui">Voice User Interface (VUI)</a> to your projects in a matter of hours. Unlike cloud-based alternatives, <a href="https://picovoice.ai/">Picovoice</a> processes voice data offline and runs entirely on Jetson Nano; processing on the edge eliminates the connectivity, latency, and privacy issues. Picovoice engines are efficient enough to run on microcontrollers, meaning the Jetson Nano has ample resources to do voice recognition.</p><p>Using <a href="http://picovoice.ai/docs/picovoice/">Picovoice SDK</a>, you will be able to infer a user’s intent from a naturally spoken utterance such as:</p><blockquote>Picovoice, set the lights in the living room to blue.</blockquote><p>Picovoice detects the occurrence of the custom wake word (“<strong>Picovoice”</strong>), and then extracts the intent from the follow-on spoken command like:</p><pre>{<br> “intent”: “changeLightColor”,<br> “slots”: {<br> “location”: “living room”,<br> “color”: “blue”<br> }<br>}</pre><p>I saw this <a href="http://gsurma.medium.com/jetson-self-driving-toy-car-part-1-4341c139c0f2">Self-Driving Toy Car </a>article recently and thought it would be fun to make it even more intelligent by controlling it with voice. Picovoice can be used through <a href="http://picovoice.ai/docs/picovoice/">multiple SDKs</a> on Jetson Nano. Let us go with Python and make our voice interface ready in 3 steps:</p><h3>0. Set up your NVIDIA Jetson Nano</h3><p>If you haven&#39;t done it yet, refer to the “<a href="http://developer.nvidia.com/embedded/learn/get-started-jetson-nano-devkit">Getting Started</a>” page.</p><h3>1. Configure your microphone</h3><p>As for the microphone, there are already several expansion boards off the shelf for Jetson Nano, but I am going with a simple USB mic.</p><p>Connect the microphone and get the list of available input audio devices by running the following command inside your terminal:</p><pre>arecord -L | grep plughw</pre><p>The output should be similar to below:</p><pre>plughw:CARD=PCH,DEV=0</pre><p>Copy this line and create a .asoundrc file in your home folder with these options:</p><pre>pcm.!default {<br>   type asym<br>   capture.pcm &quot;mic&quot;<br>}<br>pcm.mic {<br>   type plug<br>   slave {<br>      pcm &quot;${INPUT_AUDIO_DEVICE}&quot;<br>   }<br>}</pre><p>Replace ${INPUT_AUDIO_DEVICE} with what you copied earlier. You may need to reboot the system for these settings to take effect. It is also a good idea to go to Setting-&gt;Sound-&gt;Input and check if everything is working fine and that Linux identifies your microphone correctly.</p><h3>2. Install Picovoice Package</h3><p>Install the Picovoice python package:</p><pre>sudo pip3 install picovoice picovoicedemo</pre><p>The picovoicedemo package lets us test our models rapidly on Jetson Nano. The package requires a valid AccessKey. Signup or Login to <a href="https://console.picovoice.ai/">Picovoice Console</a> to get your AccessKey.</p><h3>2. Create Context model</h3><p>Go to <a href="http://picovoice.ai/console/">Picovoice Console</a>, an online, interactive tool to easily design models for both wake word (<a href="https://picovoice.ai/platform/porcupine/"><strong>Porcupine</strong></a>) and speech-to-intent (<a href="https://picovoice.ai/platform/rhino/"><strong>Rhino</strong></a>) engines inside the Picovoice SDK.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gugzkzIqkcM6P4u-reVrxA.png" /></figure><p>For this mini-project, I created a simple context, which understands changing speed (“Rate”) and turning on/off (“State”). You can copy the paragraph below and import it into Picovoice Console using the Import YAML button:</p><pre>context:<br>  expressions:<br>    changeSpeed:<br>      - Slow $Rate:rate<br>      - Speed $Rate:rate<br>      - $Rate:rate (the) speed<br>      - Set (the) speed to $pv.SingleDigitInteger:speed<br>    changeState:<br>      - &quot;[switch, turn] $State:state (the) engine&quot;<br>  slots:<br>    State:<br>      - On<br>      - Off<br>    Rate:<br>      - down<br>      - up<br>      - increase<br>      - decrease</pre><p>After training the model, download and extract it into your home folder. I also picked “computer” as the wake-word from the free wake-words available on <a href="http://github.com/Picovoice/porcupine/tree/master/resources/keyword_files/jetson">Picovoice GitHub</a>. So go ahead and tell the tiny car to turn on the “engine”:</p><blockquote>Computer, turn on the engine</blockquote><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FJ1cMYCuGYBA%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DJ1cMYCuGYBA&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FJ1cMYCuGYBA%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/2775032d7034b70a57016cfbabdd9018/href">https://medium.com/media/2775032d7034b70a57016cfbabdd9018/href</a></iframe><h3>3. Add it to your self-driving toy car project</h3><p>Thus far, we have created and tested our voice interface. Next, we will add it to a self-driving toy car project. Use the following Python code with the aforementioned Picovoice SDK for Python:<br>Just modify the wake_word_callback and inference_callback functions based on the context model’s intents.</p><pre>from picovoice import Picovoice<br> <br>keyword_path = ...<br> <br>def wake_word_callback():<br>    pass<br> <br>context_path = ...<br> <br>def inference_callback(inference):<br>    # `inference` exposes three immutable fields:<br>    # (1) `is_understood`<br>    # (2) `intent`<br>    # (3) `slots`<br>    pass<br> <br>handle = Picovoice(<br>        access_key=${ACCESS_KEY},<br>        keyword_path=keyword_path,<br>        wake_word_callback=wake_word_callback,<br>        context_path=context_path,<br>        inference_callback=inference_callback)<br>        <br>while True:<br>    handle.process(get_next_audio_frame())</pre><p>For more detailed information, please refer to the <a href="https://picovoice.ai/docs/api/picovoice-python/">Python API documentation</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bbd792afd929" width="1" height="1" alt=""><hr><p><a href="https://medium.com/picovoice/offline-speech-recognition-for-my-self-driving-toy-car-on-jetson-nano-please-bbd792afd929">“Offline speech recognition for my self-driving toy car on Jetson Nano, please!”</a> was originally published in <a href="https://medium.com/picovoice">Picovoice</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>