{"id":2194,"date":"2026-07-19T16:19:33","date_gmt":"2026-07-19T08:19:33","guid":{"rendered":"https:\/\/xlwings.net\/blog\/?p=2194"},"modified":"2026-03-28T10:19:37","modified_gmt":"2026-03-28T10:19:37","slug":"how-to-use-applicationspeech-in-the-xlwings-api-way","status":"publish","type":"post","link":"https:\/\/xlwings.net\/blog\/how-to-use-applicationspeech-in-the-xlwings-api-way\/","title":{"rendered":"How to use Application.Speech in the xlwings API way"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">The <code>Speech<\/code> member of the <code>Application<\/code> object in Excel&#8217;s object model provides access to text-to-speech functionality, allowing developers to programmatically control speech playback of cell contents. This can be particularly useful for accessibility features, data verification by auditory feedback, or creating interactive tutorials. In xlwings, this functionality is exposed through the <code>api<\/code> property, which grants direct access to the underlying Excel VBA object model, enabling the use of the <code>Speech<\/code> object&#8217;s methods and properties.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Functionality:<\/strong><br>The <code>Speech<\/code> object primarily controls the speech engine&#8217;s behavior, including speaking cell contents, managing speech playback (like pausing or resuming), and adjusting speech properties such as direction (by rows or columns) and speaking order. It allows for dynamic auditory output from spreadsheet data.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Syntax and Parameters:<\/strong><br>In xlwings, the <code>Speech<\/code> member is accessed via <code>app.api.Speech<\/code>, where <code>app<\/code> is an instance of <code>xlwings.App<\/code>. Key methods include:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>Speak(text, speakAsync, speakXML, purge)<\/code>: Speaks the specified text.<\/li>\n\n\n\n<li><code>text<\/code>: A string representing the text to be spoken.<\/li>\n\n\n\n<li><code>speakAsync<\/code>: A boolean; <code>True<\/code> for asynchronous speech (allows code to continue running), <code>False<\/code> for synchronous (code waits until speech finishes).<\/li>\n\n\n\n<li><code>speakXML<\/code>: A boolean; if <code>True<\/code>, interprets text as XML for speech synthesis control.<\/li>\n\n\n\n<li><code>purge<\/code>: A boolean; if <code>True<\/code>, purges any pending speech before speaking.<\/li>\n\n\n\n<li>Properties like <code>SpeakCellOnEnter<\/code>: A boolean property that controls whether Excel speaks the cell contents when the Enter key is pressed. It can be set or retrieved.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Code Examples:<\/strong><br>Here are practical examples using xlwings to demonstrate the <code>Speech<\/code> functionality:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Speak a Specific Text Asynchronously:<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>import xlwings as xw\napp = xw.App(visible=True)\n# Speak \"Hello from Excel\" without blocking code execution\napp.api.Speech.Speak(\"Hello from Excel\", speakAsync=True)\napp.quit()<\/code><\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>Enable Speaking Cell on Enter:<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>import xlwings as xw\napp = xw.App(visible=True)\nworkbook = app.books.open('example.xlsx')\n# Turn on speech when Enter is pressed in cells\napp.api.Speech.SpeakCellOnEnter = True\n# Now, when a user presses Enter after editing a cell, its content will be spoken\nworkbook.save()\napp.quit()<\/code><\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>Speak Cell Contents Programmatically:<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>import xlwings as xw\napp = xw.App(visible=True)\nworkbook = app.books.open('data.xlsx')\nsheet = workbook.sheets&#91;'Sheet1']\n# Get the value from cell A1 and speak it synchronously\ncell_value = sheet.range('A1').value\napp.api.Speech.Speak(str(cell_value), speakAsync=False)\napp.quit()<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The `Speech` member of the `Application` object in Excel&apos;s object model provides access to text-to-s&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25],"tags":[],"class_list":["post-2194","post","type-post","status-publish","format-standard","hentry","category-xlwings-api-reference"],"_links":{"self":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2194","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/comments?post=2194"}],"version-history":[{"count":1,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2194\/revisions"}],"predecessor-version":[{"id":3355,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2194\/revisions\/3355"}],"wp:attachment":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/media?parent=2194"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/categories?post=2194"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/tags?post=2194"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}