{
    "componentChunkName": "component---src-templates-blog-post-js",
    "path": "/python-tutorial-converting-speech-to-text/",
    "result": {"data":{"site":{"siteMetadata":{"title":"CrewCode Solutions"}},"markdownRemark":{"id":"1af3684c-e658-5671-9a2a-561a3e565085","excerpt":"In this article i will explain you how you can convert any voice data to text format in python Step 1: Install necessary python library which gonna help in…","html":"<p>In this article i will explain you how you can convert any voice data to text format in python</p>\n<h4>Step 1: Install necessary python library which gonna help in converting speech to text</h4>\n<ul>\n<li>Install SpeechRecognition python module</li>\n</ul>\n<pre><code class=\"language-py\">   #To install speech recogntion module if you are using python 3\n   sudo pip3 install SpeechRecognition\n</code></pre>\n<ul>\n<li>Install pyaudio python module linux ubuntu user</li>\n</ul>\n<pre><code class=\"language-py\">   #To install pyaudio if you are using linux ubuntu run this command\n   sudo apt-get install portaudio19-dev python-pyaudio\n\n   #After running above command run the following command\n   sudo pip3 install PyAudio\n</code></pre>\n<ul>\n<li>Install pyaudio python module windows and macos user</li>\n</ul>\n<pre><code class=\"language-py\">   pip3 install PyAudio\n</code></pre>\n<h4>Step 2: Once all the required python library installed copy paste the following code in to your python script file</h4>\n<pre><code class=\"language-py\">import speech_recognition as sr\n\nsample_rate = 48000\n\nchunk_size = 2048\n\nr = sr.Recognizer()\n\n#This will return all the list of input devices on your computer in the form of list you can select any input device and\n#and pass the index of the device as first argument of sr.Microphone function\nmic_list = sr.Microphone.list_microphone_names()\n\nwith sr.Microphone(0, sample_rate = sample_rate, chunk_size = chunk_size) as source:\n    #this will adjust the energy threshold based on the surrounding noise level\n    r.adjust_for_ambient_noise(source)\n    print (\"Tell Something\")\n    #listens for the user's input\n    audio = r.listen(source)\n\n    try:\n        text = r.recognize_google(audio)\n        print (\"you said: \",text)\n\n    #error occurs when not understand what was said\n    except sr.UnknownValueError:\n        print(\"Not able to understand your audio\")\n\n    except sr.RequestError as e:\n        print(\"Some error occured; {0}\".format(e))\n</code></pre>\n<h4>Step 3: Run the python script</h4>\n<pre><code class=\"language-py\">#In case if you are using python 3 you need to use python3 instead of python to run your script\npython your_script.py\n</code></pre>","fields":{"slug":"/python-tutorial-converting-speech-to-text/"},"frontmatter":{"title":"Python tutorial converting speech to text using python script","date":"January 08, 2023","description":"In this article i will explain you step by step how you can convert any voice to text in python","bannerimage":"https://crew-code-images.s3.us-east-1.amazonaws.com/blog_images/python.jpg"}},"previous":{"fields":{"slug":"/python-scrap-data-from-url/"},"frontmatter":{"title":"Python how to scrap data from any url","date":"January 01, 2023","bannerimage":"https://crew-code-images.s3.us-east-1.amazonaws.com/blog_images/python.jpg"}},"next":{"fields":{"slug":"/python-tutorial-creating-voice-assistant/"},"frontmatter":{"title":"Python tutorial creating voice assistant using python","date":"January 18, 2023","bannerimage":"https://crew-code-images.s3.us-east-1.amazonaws.com/blog_images/python.jpg"}}},"pageContext":{"id":"1af3684c-e658-5671-9a2a-561a3e565085","previousPostId":"55d25ca7-2fd8-5d83-8882-53b080593b25","nextPostId":"3797002a-529d-5f2b-8117-13367f479914"}},
    "staticQueryHashes": ["3860684146"]}