{"id":8969,"date":"2021-12-08T17:08:19","date_gmt":"2021-12-08T16:08:19","guid":{"rendered":"https:\/\/monodes.com\/predaelli\/?p=8969"},"modified":"2021-12-08T17:08:19","modified_gmt":"2021-12-08T16:08:19","slug":"converting-speech-to-text-in-10-minutes-with-python-and-watson","status":"publish","type":"post","link":"https:\/\/monodes.com\/predaelli\/2021\/12\/08\/converting-speech-to-text-in-10-minutes-with-python-and-watson\/","title":{"rendered":"Converting Speech to Text in 10 Minutes with Python and Watson"},"content":{"rendered":"<p>Ok, it&#8217;s not free-as-in-freedom, but someone nevertheless could find it useful&#8230;<\/p>\n<h2><em><a href=\"https:\/\/morioh.com\">Converting Speech to Text in 10 Minutes with Python and Watson<\/a><\/em><\/h2>\n<blockquote><p>Social network for developers to discuss topics about bugs and issues, write and share knowledge and connect with millions of developers worldwide.<\/p><\/blockquote>\n<p>&nbsp;<\/p>\n<p><!--more--><\/p>\n<blockquote>\n<div class=\"min-w-0 flex-1\">\n<p class=\"text-base font-medium\"><a class=\"hover:underline\" href=\"https:\/\/morioh.com\/@602d42684082950f6bb722c3\">Regie Lucas<\/a><\/p>\n<p class=\"text-sm text-gray-500\"><a class=\"router-link-active active hover:underline\" href=\"https:\/\/morioh.com\/p\/42c0f9a175c1\" aria-current=\"page\">9 months ago<\/a><\/p>\n<\/div>\n<div class=\"flex-shrink-0 self-center flex space-x-6\">\n<div class=\"relative inline-block text-left\">\n<div><\/div>\n<\/div>\n<\/div>\n<div class=\"flex space-x-3 p-4\">\n<div class=\"flex-shrink-0 self-center flex space-x-6\">\n<div class=\"relative inline-block text-left\"><\/div>\n<\/div>\n<\/div>\n<div class=\"p-4 pt-0\">\n<div class=\"overflow-hidden max-w-none prose visited:text-purple-600\">\n<div>\n<p>Don\u2019t waste your time doing this by hand, you can speed up this process using Watson Speech to Text and Python. In just ten minutes you can have your own speech to text model converting audio files to text. That way you can get the boring stuff out of the way a whole lot faster.<\/p>\n<p>In this video you\u2019ll learn how to:<\/p>\n<ol>\n<li>Set up the Watson Speech to Text Service<\/li>\n<li>Convert Speech to Text using Python and the Watson API<\/li>\n<li>Changing language models to suit your accent or language<\/li>\n<\/ol>\n<p>Github Repo for the Project: <a href=\"https:\/\/github.com\/nicknochnack\/WatsonSTT\" target=\"_blank\" rel=\"noopener nofollow\">https:\/\/github.com\/nicknochnack\/WatsonSTT<\/a><\/p>\n<p>Subscribe: <a href=\"https:\/\/www.youtube.com\/channel\/UCHXa4OpASJEwrHrLeIzw7Yg\" target=\"_blank\" rel=\"noopener nofollow\">https:\/\/www.youtube.com\/channel\/UCHXa4OpASJEwrHrLeIzw7Yg<\/a><\/p>\n<p>Here&#8217;s the entire content of the &#8220;Watson Speech to Text.ipynb&#8221; file:<\/p>\n<pre>{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"## 0. Install and Import Dependencies\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": 1,\n   \"metadata\": {\n    \"collapsed\": true\n   },\n   \"outputs\": [\n    {\n     \"name\": \"stdout\",\n     \"output_type\": \"stream\",\n     \"text\": [\n      \"Requirement already satisfied: ibm_watson in \/Users\/nicholasrenotte\/opt\/anaconda3\/lib\/python3.7\/site-packages (4.5.0)\\n\",\n      \"Requirement already satisfied: websocket-client==0.48.0 in \/Users\/nicholasrenotte\/opt\/anaconda3\/lib\/python3.7\/site-packages (from ibm_watson) (0.48.0)\\n\",\n      \"Requirement already satisfied: requests&lt;3.0,&gt;=2.0 in \/Users\/nicholasrenotte\/opt\/anaconda3\/lib\/python3.7\/site-packages (from ibm_watson) (2.22.0)\\n\",\n      \"Requirement already satisfied: ibm-cloud-sdk-core==1.5.1 in \/Users\/nicholasrenotte\/opt\/anaconda3\/lib\/python3.7\/site-packages (from ibm_watson) (1.5.1)\\n\",\n      \"Requirement already satisfied: python-dateutil&gt;=2.5.3 in \/Users\/nicholasrenotte\/opt\/anaconda3\/lib\/python3.7\/site-packages (from ibm_watson) (2.8.0)\\n\",\n      \"Requirement already satisfied: six in \/Users\/nicholasrenotte\/opt\/anaconda3\/lib\/python3.7\/site-packages (from websocket-client==0.48.0-&gt;ibm_watson) (1.12.0)\\n\",\n      \"Requirement already satisfied: certifi&gt;=2017.4.17 in \/Users\/nicholasrenotte\/opt\/anaconda3\/lib\/python3.7\/site-packages (from requests&lt;3.0,&gt;=2.0-&gt;ibm_watson) (2019.9.11)\\n\",\n      \"Requirement already satisfied: idna&lt;2.9,&gt;=2.5 in \/Users\/nicholasrenotte\/opt\/anaconda3\/lib\/python3.7\/site-packages (from requests&lt;3.0,&gt;=2.0-&gt;ibm_watson) (2.8)\\n\",\n      \"Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,&lt;1.26,&gt;=1.21.1 in \/Users\/nicholasrenotte\/opt\/anaconda3\/lib\/python3.7\/site-packages (from requests&lt;3.0,&gt;=2.0-&gt;ibm_watson) (1.24.2)\\n\",\n      \"Requirement already satisfied: chardet&lt;3.1.0,&gt;=3.0.2 in \/Users\/nicholasrenotte\/opt\/anaconda3\/lib\/python3.7\/site-packages (from requests&lt;3.0,&gt;=2.0-&gt;ibm_watson) (3.0.4)\\n\",\n      \"Requirement already satisfied: PyJWT&gt;=1.7.1 in \/Users\/nicholasrenotte\/opt\/anaconda3\/lib\/python3.7\/site-packages (from ibm-cloud-sdk-core==1.5.1-&gt;ibm_watson) (1.7.1)\\n\"\n     ]\n    }\n   ],\n   \"source\": [\n    \"!pip install ibm_watson\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": 10,\n   \"metadata\": {},\n   \"outputs\": [],\n   \"source\": [\n    \"from ibm_watson import SpeechToTextV1\\n\",\n    \"from ibm_watson.websocket import RecognizeCallback, AudioSource \\n\",\n    \"from ibm_cloud_sdk_core.authenticators import IAMAuthenticator\"\n   ]\n  },\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"## 1. Setup STT Service\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": 11,\n   \"metadata\": {},\n   \"outputs\": [],\n   \"source\": [\n    \"apikey = 'API KEY'\\n\",\n    \"url = 'URL'\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": 12,\n   \"metadata\": {},\n   \"outputs\": [],\n   \"source\": [\n    \"# Setup Service\\n\",\n    \"authenticator = IAMAuthenticator(apikey)\\n\",\n    \"stt = SpeechToTextV1(authenticator=authenticator)\\n\",\n    \"stt.set_service_url(url)\"\n   ]\n  },\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"## 2. Open Audio Source and Convert\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": 16,\n   \"metadata\": {},\n   \"outputs\": [],\n   \"source\": [\n    \"# Perform conversion\\n\",\n    \"with open('Untitled.mp3', 'rb') as f:\\n\",\n    \"    res = stt.recognize(audio=f, content_type='audio\/mp3', model='en-US_NarrowbandModel', continuous=True).get_result()\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": 17,\n   \"metadata\": {},\n   \"outputs\": [\n    {\n     \"data\": {\n      \"text\/plain\": [\n       \"{'result_index': 0,\\n\",\n       \" 'results': [{'final': True,\\n\",\n       \"   'alternatives': [{'transcript': 'hello well ', 'confidence': 0.8}]}]}\"\n      ]\n     },\n     \"execution_count\": 17,\n     \"metadata\": {},\n     \"output_type\": \"execute_result\"\n    }\n   ],\n   \"source\": [\n    \"res\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": 18,\n   \"metadata\": {},\n   \"outputs\": [\n    {\n     \"data\": {\n      \"text\/plain\": [\n       \"'hello well '\"\n      ]\n     },\n     \"execution_count\": 18,\n     \"metadata\": {},\n     \"output_type\": \"execute_result\"\n    }\n   ],\n   \"source\": [\n    \"text = res['results'][0]['alternatives'][0]['transcript']\\n\",\n    \"text\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": 19,\n   \"metadata\": {},\n   \"outputs\": [\n    {\n     \"data\": {\n      \"text\/plain\": [\n       \"0.8\"\n      ]\n     },\n     \"execution_count\": 19,\n     \"metadata\": {},\n     \"output_type\": \"execute_result\"\n    }\n   ],\n   \"source\": [\n    \"confidence = res['results'][0]['alternatives'][0]['confidence']\\n\",\n    \"confidence\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": 20,\n   \"metadata\": {},\n   \"outputs\": [],\n   \"source\": [\n    \"with open('output.txt', 'w') as out:\\n\",\n    \"    out.writelines(text)\"\n   ]\n  },\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"## 3. Change Language Models\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": 21,\n   \"metadata\": {},\n   \"outputs\": [],\n   \"source\": [\n    \"# Perform conversion\\n\",\n    \"with open('Untitled.mp3', 'rb') as f:\\n\",\n    \"    res = stt.recognize(audio=f, content_type='audio\/mp3', model='en-AU_NarrowbandModel', continuous=True).get_result()\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": 22,\n   \"metadata\": {},\n   \"outputs\": [\n    {\n     \"data\": {\n      \"text\/plain\": [\n       \"{'result_index': 0,\\n\",\n       \" 'results': [{'final': True,\\n\",\n       \"   'alternatives': [{'transcript': 'hello world ', 'confidence': 0.99}]}]}\"\n      ]\n     },\n     \"execution_count\": 22,\n     \"metadata\": {},\n     \"output_type\": \"execute_result\"\n    }\n   ],\n   \"source\": [\n    \"res\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": null,\n   \"metadata\": {},\n   \"outputs\": [],\n   \"source\": []\n  }\n ],\n \"metadata\": {\n  \"kernelspec\": {\n   \"display_name\": \"Python 3\",\n   \"language\": \"python\",\n   \"name\": \"python3\"\n  },\n  \"language_info\": {\n   \"codemirror_mode\": {\n    \"name\": \"ipython\",\n    \"version\": 3\n   },\n   \"file_extension\": \".py\",\n   \"mimetype\": \"text\/x-python\",\n   \"name\": \"python\",\n   \"nbconvert_exporter\": \"python\",\n   \"pygments_lexer\": \"ipython3\",\n   \"version\": \"3.7.4\"\n  }\n },\n \"nbformat\": 4,\n \"nbformat_minor\": 2\n}\n<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p class=\"excerpt\">Ok, it&#8217;s not free-as-in-freedom, but someone nevertheless could find it useful&#8230; Converting Speech to Text in 10 Minutes with Python and Watson Social network for developers to discuss topics about bugs and issues, write and share knowledge and connect with millions of developers worldwide. &nbsp;<\/p>\n<p class=\"more-link-p\"><a class=\"more-link\" href=\"https:\/\/monodes.com\/predaelli\/2021\/12\/08\/converting-speech-to-text-in-10-minutes-with-python-and-watson\/\">Read more &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":4,"activitypub_interaction_policy_quote":"anyone","activitypub_status":"","footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[72],"tags":[],"class_list":["post-8969","post","type-post","status-publish","format-standard","hentry","category-documentations"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p6daft-2kF","jetpack-related-posts":[{"id":7795,"url":"https:\/\/monodes.com\/predaelli\/2020\/12\/02\/rich-text-on-terminal-in-python\/","url_meta":{"origin":8969,"position":0},"title":"Rich text on terminal in Python","author":"Paolo Redaelli","date":"2020-12-02","format":"link","excerpt":"Rich is a Python library for rich text and beautiful formatting in the terminal.","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/monodes.com\/predaelli\/category\/python\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/monodes.com\/predaelli\/wp-content\/uploads\/sites\/4\/2020\/12\/rich.python-features.png?fit=1131%2C1200&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/monodes.com\/predaelli\/wp-content\/uploads\/sites\/4\/2020\/12\/rich.python-features.png?fit=1131%2C1200&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/monodes.com\/predaelli\/wp-content\/uploads\/sites\/4\/2020\/12\/rich.python-features.png?fit=1131%2C1200&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/monodes.com\/predaelli\/wp-content\/uploads\/sites\/4\/2020\/12\/rich.python-features.png?fit=1131%2C1200&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/monodes.com\/predaelli\/wp-content\/uploads\/sites\/4\/2020\/12\/rich.python-features.png?fit=1131%2C1200&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":4626,"url":"https:\/\/monodes.com\/predaelli\/2018\/10\/09\/jupyter\/","url_meta":{"origin":8969,"position":1},"title":"Jupyter","author":"Paolo Redaelli","date":"2018-10-09","format":"link","excerpt":"Sorgente: Economics Nobel Laureate Paul Romer Is a Python Programming Convert - Slashdot It's time to re-evaluate Jupyter","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/monodes.com\/predaelli\/category\/python\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":9674,"url":"https:\/\/monodes.com\/predaelli\/2022\/09\/28\/10-powerful-python-one-liners\/","url_meta":{"origin":8969,"position":2},"title":"10 Powerful Python One-Liners.","author":"Paolo Redaelli","date":"2022-09-28","format":false,"excerpt":"I shall Eiffellize those, one day or another: 10 Powerful Python One-Liners. Python one-liners can be just as\u2026 | by Ishaan Gupta | Sep, 2022 | Python in Plain English 10 Powerful Python One-Liners Python one-liners can be just as powerful as a long and tedious program written in another\u2026","rel":"","context":"In &quot;Agenda&quot;","block_context":{"text":"Agenda","link":"https:\/\/monodes.com\/predaelli\/category\/agenda\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/monodes.com\/predaelli\/wp-content\/uploads\/sites\/4\/2022\/09\/1jLSxNQvNqsYr02VB_wr96A.jpeg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/monodes.com\/predaelli\/wp-content\/uploads\/sites\/4\/2022\/09\/1jLSxNQvNqsYr02VB_wr96A.jpeg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/monodes.com\/predaelli\/wp-content\/uploads\/sites\/4\/2022\/09\/1jLSxNQvNqsYr02VB_wr96A.jpeg?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":8567,"url":"https:\/\/monodes.com\/predaelli\/2021\/07\/18\/kivy-cross-platform-python-framework-for-nui-development\/","url_meta":{"origin":8969,"position":3},"title":"Kivy: Cross-platform Python Framework for NUI Development","author":"Paolo Redaelli","date":"2021-07-18","format":"link","excerpt":"https:\/\/kivy.org\/#home","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/monodes.com\/predaelli\/category\/python\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":6318,"url":"https:\/\/monodes.com\/predaelli\/2019\/12\/15\/eiffels-conditional-expressions\/","url_meta":{"origin":8969,"position":4},"title":"Eiffel&#8217;s conditional expressions","author":"Paolo Redaelli","date":"2019-12-15","format":false,"excerpt":"The ternary conditional operator is a short-hand method for writing an if\/else statement. Does Python Have a Ternary Conditional Operator? Yes, it does. This remids me that Eiffel, at least \"ISE Eiffel\" does actually have conditional expressions that are the same: answer := if time < noon then \"Good morning\"\u2026","rel":"","context":"In &quot;Eiffel&quot;","block_context":{"text":"Eiffel","link":"https:\/\/monodes.com\/predaelli\/category\/eiffel\/"},"img":{"alt_text":"Jonathan Hsu","src":"https:\/\/i0.wp.com\/miro.medium.com\/fit\/c\/58\/58\/2%2A_KGzadiy9s83D4vzhsCyyg.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":12907,"url":"https:\/\/monodes.com\/predaelli\/2025\/03\/07\/27-year-old-exe-becomes-python-in-minutes-with-claude-ai-assisted-reverse-engineering-adafruit-industries-makers-hackers-artists-designers-and-engineers\/","url_meta":{"origin":8969,"position":5},"title":"27-Year-Old EXE becomes Python in minutes (with Claude) \u2013 AI-Assisted reverse engineering \u00ab Adafruit Industries \u2013 Makers, hackers, artists, designers and engineers!","author":"Paolo Redaelli","date":"2025-03-07","format":"link","excerpt":"Reddit post detailing how someone took a 27-year-old visual basic EXE file, fed it to Claude 3.7, and watched as it reverse-engineered the program and rewrote it in Python. It was an old Visual Bas\u2026 Source: 27-Year-Old EXE becomes Python in minutes (with Claude) \u2013 AI-Assisted reverse engineering \u00ab Adafruit\u2026","rel":"","context":"In &quot;Senza categoria&quot;","block_context":{"text":"Senza categoria","link":"https:\/\/monodes.com\/predaelli\/category\/senza-categoria\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/posts\/8969","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/comments?post=8969"}],"version-history":[{"count":0,"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/posts\/8969\/revisions"}],"wp:attachment":[{"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/media?parent=8969"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/categories?post=8969"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/tags?post=8969"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}