{"id":288,"date":"2023-12-11T12:43:25","date_gmt":"2023-12-11T17:43:25","guid":{"rendered":"https:\/\/leapfrog.hopto.org\/wolfy\/?page_id=288"},"modified":"2023-12-11T14:45:21","modified_gmt":"2023-12-11T19:45:21","slug":"speech-decomposition","status":"publish","type":"page","link":"https:\/\/leapfrog.hopto.org\/wolfy\/?page_id=288","title":{"rendered":"Speech Decomposition"},"content":{"rendered":"\n<p>The idea is to approximate .wav files with sets of sine waves. Then we use the sine wave coefficients as basis functions to describe and recognize speech contained in new .wav files.<\/p>\n\n\n\n<p>Math <a href=\"https:\/\/stackoverflow.com\/questions\/38832474\/curve-fitting-in-matlab-for-a-sinusoidal-function-with-more-than-8-terms\" data-type=\"link\" data-id=\"https:\/\/stackoverflow.com\/questions\/38832474\/curve-fitting-in-matlab-for-a-sinusoidal-function-with-more-than-8-terms\">summary<\/a> as a MATLAB script (I&#8217;ll be using Octave):<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">clear;clc\nxdata=1:0.1:10; % X or Independant Data\nydata=sin(xdata+0.2)+0.5*sin(0.3*xdata+0.3)+ 2*sin( 0.2*xdata+23 )+...\n    0.7*sin( 0.34*xdata+12 )+.76*sin( .23*xdata+.3 )+.98*sin(.76 *xdata+.56 )+...\n    +.34*sin( .87*xdata+.123 )+.234*sin(.234 *xdata+23 ); % Y or Dependant data \nx0 = randn(36,1);  % Initial Guess\nfun = @(x,xdata)x(1)*sin(x(2)*xdata+x(3))+... \n                x(4)*sin(x(5)*xdata+x(6))+...\n                x(7)*sin(x(8)*xdata+x(9))+...\n              x(10)*sin(x(11)*xdata+x(12))+...\n              x(13)*sin(x(14)*xdata+x(15))+...\n              x(16)*sin(x(17)*xdata+x(18))+...\n              x(19)*sin(x(20)*xdata+x(21))+...\n              x(22)*sin(x(23)*xdata+x(24))+...\n              x(25)*sin(x(26)*xdata+x(27))+...\n              x(28)*sin(x(29)*xdata+x(30))+...\n              x(31)*sin(x(32)*xdata+x(33))+...\n              x(34)*sin(x(35)*xdata+x(36)); % Goal function which is Sum of 12 sines\noptions = optimoptions('lsqcurvefit','Algorithm','trust-region-reflective');% Options for fitting \nx=lsqcurvefit(fun,x0,xdata,ydata) % the main instruction\ntimes = linspace(xdata(1),xdata(end));\nplot(xdata,ydata,'ko',times,fun(x,times),'r-')\nlegend('Data','Fitted Sum of 12 Sines')\ntitle('Data and Fitted Curve')\n\nTo run this in Octave requires the octave-dev and the Optimization package.<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The idea is to approximate .wav files with sets of sine waves. Then we use the sine wave coefficients as basis functions to describe and recognize speech contained in new .wav files. Math summary as a MATLAB script (I&#8217;ll be using Octave): clear;clc xdata=1:0.1:10; % X or Independant Data ydata=sin(xdata+0.2)+0.5*sin(0.3*xdata+0.3)+ 2*sin( 0.2*xdata+23 )+&#8230; 0.7*sin( 0.34*xdata+12 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-288","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/leapfrog.hopto.org\/wolfy\/index.php?rest_route=\/wp\/v2\/pages\/288","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/leapfrog.hopto.org\/wolfy\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/leapfrog.hopto.org\/wolfy\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/leapfrog.hopto.org\/wolfy\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/leapfrog.hopto.org\/wolfy\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=288"}],"version-history":[{"count":4,"href":"https:\/\/leapfrog.hopto.org\/wolfy\/index.php?rest_route=\/wp\/v2\/pages\/288\/revisions"}],"predecessor-version":[{"id":293,"href":"https:\/\/leapfrog.hopto.org\/wolfy\/index.php?rest_route=\/wp\/v2\/pages\/288\/revisions\/293"}],"wp:attachment":[{"href":"https:\/\/leapfrog.hopto.org\/wolfy\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=288"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}