{"id":4291,"date":"2021-12-29T11:33:25","date_gmt":"2021-12-29T10:33:25","guid":{"rendered":"https:\/\/www.pschatzmann.ch\/home\/?p=4291"},"modified":"2022-02-16T19:43:41","modified_gmt":"2022-02-16T18:43:41","slug":"the-audiokit-and-the-sam-tts-engine","status":"publish","type":"post","link":"https:\/\/www.pschatzmann.ch\/home\/2021\/12\/29\/the-audiokit-and-the-sam-tts-engine\/","title":{"rendered":"Using the SAM TTS Engine with the Audiokit"},"content":{"rendered":"<p>I decided to use my <a href=\"https:\/\/github.com\/pschatzmann\/arduino-SAM\">SAM TTS Library<\/a> with the <a href=\"https:\/\/www.pschatzmann.ch\/home\/2021\/12\/06\/the-ai-thinker-audio-kit-experience-or-nothing-is-right\/\"><strong>AI Thinker Audio Kit<\/strong><\/a>. Unfortunately I found quite some bugs in my library that I needed to correct first, but now it is working as expected. Here is the Arduino Sketch<\/p>\n<pre><code>#include \"sam_arduino.h\"\n#include \"AudioTools.h\"\n#include \"AudioLibs\/AudioKit.h\"\n\nAudioKitStream kit;\nSAM sam(kit);\n\nconst char* text = \"Hallo my name is SAM\";\n\nvoid setup(){\n  Serial.begin(115200);\n  AudioLogger::instance().begin(Serial, AudioLogger::Info);\n\n  \/\/ setup i2s\n  auto cfg = kit.defaultConfig();\n  cfg.bits_per_sample = sam.bitsPerSample();\n  cfg.channels = sam.channels();\n  cfg.sample_rate = sam.sampleRate();\n  kit.begin(cfg);\n\n  sam.say(text);\n}\n\nvoid loop() {\n  delay(100);\n}\n\n<\/code><\/pre>\n<p>We can use the stream output support of SAM and because the AudioKitStream is implementing the Arduino Stream, we can provide it directly as output argument. In the setup we just need to make sure that we use the correct I2S parameters: Fortunately SAM can provide this info to us.<\/p>\n<p>The sound quality is much inferior to what we get from <a href=\"https:\/\/www.pschatzmann.ch\/home\/2021\/12\/08\/using-flite-with-the-ai-thinker-audio-kit\/\">FLITE<\/a> &#8211; but it uses less memory:<\/p>\n<pre><code>Sketch uses 557245 bytes (17%) of program storage space. Maximum is 3145728 bytes.\nGlobal variables use 25876 bytes (7%) of dynamic memory, leaving 301804 bytes for local variables. Maximum is 327680 bytes.\n<\/code><\/pre>\n<h2>Source Code<\/h2>\n<p>The (potentially) updated source code can be found in the <a href=\"https:\/\/github.com\/pschatzmann\/arduino-audio-tools\/tree\/main\/examples\/examples-audiokit\/streams-sam-audiokit\">samples directory of my AudioTools library<\/a>.<\/p>\n<h3>Dependencies<\/h3>\n<p>You need to install the following libraries:<\/p>\n<ul>\n<li><a href=\"https:\/\/github.com\/pschatzmann\/arduino-audio-tools\">Arduino Audio Tolls<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/pschatzmann\/arduino-audiokit\">AudioKit<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/pschatzmann\/arduino-SAM\">SAM<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>I decided to use my SAM TTS Library with the AI Thinker Audio Kit. Unfortunately I found quite some bugs in my library that I needed to correct first, but now it is working as expected. Here is the Arduino Sketch #include &#8220;sam_arduino.h&#8221; #include &#8220;AudioTools.h&#8221; #include &#8220;AudioLibs\/AudioKit.h&#8221; AudioKitStream kit; SAM [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3882,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[20,22,35],"tags":[28,27],"class_list":["post-4291","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-arduino","category-machine-sound","category-text-to-speech","tag-esp32audiokit","tag-tts"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Using the SAM TTS Engine with the Audiokit - Phil Schatzmann<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.pschatzmann.ch\/home\/2021\/12\/29\/the-audiokit-and-the-sam-tts-engine\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Using the SAM TTS Engine with the Audiokit - Phil Schatzmann\" \/>\n<meta property=\"og:description\" content=\"I decided to use my SAM TTS Library with the AI Thinker Audio Kit. Unfortunately I found quite some bugs in my library that I needed to correct first, but now it is working as expected. Here is the Arduino Sketch #include &quot;sam_arduino.h&quot; #include &quot;AudioTools.h&quot; #include &quot;AudioLibs\/AudioKit.h&quot; AudioKitStream kit; SAM [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.pschatzmann.ch\/home\/2021\/12\/29\/the-audiokit-and-the-sam-tts-engine\/\" \/>\n<meta property=\"og:site_name\" content=\"Phil Schatzmann\" \/>\n<meta property=\"article:published_time\" content=\"2021-12-29T10:33:25+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-02-16T18:43:41+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2021\/12\/audio-toolkit.png\" \/>\n\t<meta property=\"og:image:width\" content=\"800\" \/>\n\t<meta property=\"og:image:height\" content=\"500\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"pschatzmann\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"pschatzmann\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2021\\\/12\\\/29\\\/the-audiokit-and-the-sam-tts-engine\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2021\\\/12\\\/29\\\/the-audiokit-and-the-sam-tts-engine\\\/\"},\"author\":{\"name\":\"pschatzmann\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#\\\/schema\\\/person\\\/73a53638a4e34e8373405fd737dac9b1\"},\"headline\":\"Using the SAM TTS Engine with the Audiokit\",\"datePublished\":\"2021-12-29T10:33:25+00:00\",\"dateModified\":\"2022-02-16T18:43:41+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2021\\\/12\\\/29\\\/the-audiokit-and-the-sam-tts-engine\\\/\"},\"wordCount\":149,\"commentCount\":4,\"publisher\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#\\\/schema\\\/person\\\/73a53638a4e34e8373405fd737dac9b1\"},\"image\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2021\\\/12\\\/29\\\/the-audiokit-and-the-sam-tts-engine\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2021\\\/12\\\/audio-toolkit.png\",\"keywords\":[\"ESP32AudioKit\",\"TTS\"],\"articleSection\":[\"Arduino\",\"Machine Sound\",\"Text To Speech\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2021\\\/12\\\/29\\\/the-audiokit-and-the-sam-tts-engine\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2021\\\/12\\\/29\\\/the-audiokit-and-the-sam-tts-engine\\\/\",\"url\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2021\\\/12\\\/29\\\/the-audiokit-and-the-sam-tts-engine\\\/\",\"name\":\"Using the SAM TTS Engine with the Audiokit - Phil Schatzmann\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2021\\\/12\\\/29\\\/the-audiokit-and-the-sam-tts-engine\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2021\\\/12\\\/29\\\/the-audiokit-and-the-sam-tts-engine\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2021\\\/12\\\/audio-toolkit.png\",\"datePublished\":\"2021-12-29T10:33:25+00:00\",\"dateModified\":\"2022-02-16T18:43:41+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2021\\\/12\\\/29\\\/the-audiokit-and-the-sam-tts-engine\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2021\\\/12\\\/29\\\/the-audiokit-and-the-sam-tts-engine\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2021\\\/12\\\/29\\\/the-audiokit-and-the-sam-tts-engine\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2021\\\/12\\\/audio-toolkit.png\",\"contentUrl\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2021\\\/12\\\/audio-toolkit.png\",\"width\":800,\"height\":500},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2021\\\/12\\\/29\\\/the-audiokit-and-the-sam-tts-engine\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Using the SAM TTS Engine with the Audiokit\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#website\",\"url\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/\",\"name\":\"Phil Schatzmann Consulting\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#\\\/schema\\\/person\\\/73a53638a4e34e8373405fd737dac9b1\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#\\\/schema\\\/person\\\/73a53638a4e34e8373405fd737dac9b1\",\"name\":\"pschatzmann\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/pschatzmann.png\",\"url\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/pschatzmann.png\",\"contentUrl\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/pschatzmann.png\",\"width\":305,\"height\":305,\"caption\":\"pschatzmann\"},\"logo\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/pschatzmann.png\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Using the SAM TTS Engine with the Audiokit - Phil Schatzmann","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.pschatzmann.ch\/home\/2021\/12\/29\/the-audiokit-and-the-sam-tts-engine\/","og_locale":"en_US","og_type":"article","og_title":"Using the SAM TTS Engine with the Audiokit - Phil Schatzmann","og_description":"I decided to use my SAM TTS Library with the AI Thinker Audio Kit. Unfortunately I found quite some bugs in my library that I needed to correct first, but now it is working as expected. Here is the Arduino Sketch #include \"sam_arduino.h\" #include \"AudioTools.h\" #include \"AudioLibs\/AudioKit.h\" AudioKitStream kit; SAM [&hellip;]","og_url":"https:\/\/www.pschatzmann.ch\/home\/2021\/12\/29\/the-audiokit-and-the-sam-tts-engine\/","og_site_name":"Phil Schatzmann","article_published_time":"2021-12-29T10:33:25+00:00","article_modified_time":"2022-02-16T18:43:41+00:00","og_image":[{"width":800,"height":500,"url":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2021\/12\/audio-toolkit.png","type":"image\/png"}],"author":"pschatzmann","twitter_card":"summary_large_image","twitter_misc":{"Written by":"pschatzmann","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.pschatzmann.ch\/home\/2021\/12\/29\/the-audiokit-and-the-sam-tts-engine\/#article","isPartOf":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2021\/12\/29\/the-audiokit-and-the-sam-tts-engine\/"},"author":{"name":"pschatzmann","@id":"https:\/\/www.pschatzmann.ch\/home\/#\/schema\/person\/73a53638a4e34e8373405fd737dac9b1"},"headline":"Using the SAM TTS Engine with the Audiokit","datePublished":"2021-12-29T10:33:25+00:00","dateModified":"2022-02-16T18:43:41+00:00","mainEntityOfPage":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2021\/12\/29\/the-audiokit-and-the-sam-tts-engine\/"},"wordCount":149,"commentCount":4,"publisher":{"@id":"https:\/\/www.pschatzmann.ch\/home\/#\/schema\/person\/73a53638a4e34e8373405fd737dac9b1"},"image":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2021\/12\/29\/the-audiokit-and-the-sam-tts-engine\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2021\/12\/audio-toolkit.png","keywords":["ESP32AudioKit","TTS"],"articleSection":["Arduino","Machine Sound","Text To Speech"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.pschatzmann.ch\/home\/2021\/12\/29\/the-audiokit-and-the-sam-tts-engine\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.pschatzmann.ch\/home\/2021\/12\/29\/the-audiokit-and-the-sam-tts-engine\/","url":"https:\/\/www.pschatzmann.ch\/home\/2021\/12\/29\/the-audiokit-and-the-sam-tts-engine\/","name":"Using the SAM TTS Engine with the Audiokit - Phil Schatzmann","isPartOf":{"@id":"https:\/\/www.pschatzmann.ch\/home\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2021\/12\/29\/the-audiokit-and-the-sam-tts-engine\/#primaryimage"},"image":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2021\/12\/29\/the-audiokit-and-the-sam-tts-engine\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2021\/12\/audio-toolkit.png","datePublished":"2021-12-29T10:33:25+00:00","dateModified":"2022-02-16T18:43:41+00:00","breadcrumb":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2021\/12\/29\/the-audiokit-and-the-sam-tts-engine\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.pschatzmann.ch\/home\/2021\/12\/29\/the-audiokit-and-the-sam-tts-engine\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pschatzmann.ch\/home\/2021\/12\/29\/the-audiokit-and-the-sam-tts-engine\/#primaryimage","url":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2021\/12\/audio-toolkit.png","contentUrl":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2021\/12\/audio-toolkit.png","width":800,"height":500},{"@type":"BreadcrumbList","@id":"https:\/\/www.pschatzmann.ch\/home\/2021\/12\/29\/the-audiokit-and-the-sam-tts-engine\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.pschatzmann.ch\/home\/"},{"@type":"ListItem","position":2,"name":"Using the SAM TTS Engine with the Audiokit"}]},{"@type":"WebSite","@id":"https:\/\/www.pschatzmann.ch\/home\/#website","url":"https:\/\/www.pschatzmann.ch\/home\/","name":"Phil Schatzmann Consulting","description":"","publisher":{"@id":"https:\/\/www.pschatzmann.ch\/home\/#\/schema\/person\/73a53638a4e34e8373405fd737dac9b1"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.pschatzmann.ch\/home\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/www.pschatzmann.ch\/home\/#\/schema\/person\/73a53638a4e34e8373405fd737dac9b1","name":"pschatzmann","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/08\/pschatzmann.png","url":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/08\/pschatzmann.png","contentUrl":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/08\/pschatzmann.png","width":305,"height":305,"caption":"pschatzmann"},"logo":{"@id":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/08\/pschatzmann.png"}}]}},"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/posts\/4291","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/comments?post=4291"}],"version-history":[{"count":18,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/posts\/4291\/revisions"}],"predecessor-version":[{"id":4310,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/posts\/4291\/revisions\/4310"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/media\/3882"}],"wp:attachment":[{"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/media?parent=4291"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/categories?post=4291"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/tags?post=4291"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}