<?xml version='1.0' encoding="utf-8"?>
      <rss version='2.0'>
      <channel>
      <title>Форум на Исходниках.RU</title>
      <link>https://forum.sources.ru</link>
      <description>Форум на Исходниках.RU</description>
      <generator>Форум на Исходниках.RU</generator>
  	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=404097&amp;view=findpost&amp;p=3663054</guid>
        <pubDate>Sat, 02 Apr 2016 04:58:21 +0000</pubDate>
        <title>Подключение PocketSphinx к C#</title>
        <link>https://forum.sources.ru/index.php?showtopic=404097&amp;view=findpost&amp;p=3663054</link>
        <description><![CDATA[ivan7271: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=404097&view=findpost&p=3612365'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>paulboxer &#064; <time class="tag-quote__quoted-time" datetime="2015-07-12T20:21:08+03:00">12.07.15, 17:21</time></span><div class='quote '><strong class='tag-b'>nsh</strong>спасибо за ответ буду разбираться...</div></div><br>
Здравствуйте.<br>
Удалось ли вам найти решение?<br>
Ищу решение такой же задачи. Возможно, кто-нибудь может помочь?<br>
Заранее благодарен.]]></description>
        <author>ivan7271</author>
        <category>Речевые Технологии</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=404097&amp;view=findpost&amp;p=3612365</guid>
        <pubDate>Sun, 12 Jul 2015 17:21:08 +0000</pubDate>
        <title>Подключение PocketSphinx к C#</title>
        <link>https://forum.sources.ru/index.php?showtopic=404097&amp;view=findpost&amp;p=3612365</link>
        <description><![CDATA[paulboxer: <strong class='tag-b'>nsh</strong>спасибо за ответ буду разбираться...]]></description>
        <author>paulboxer</author>
        <category>Речевые Технологии</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=404097&amp;view=findpost&amp;p=3612353</guid>
        <pubDate>Sun, 12 Jul 2015 16:21:26 +0000</pubDate>
        <title>Подключение PocketSphinx к C#</title>
        <link>https://forum.sources.ru/index.php?showtopic=404097&amp;view=findpost&amp;p=3612353</link>
        <description><![CDATA[nsh: Задавать дополнительные параметры конфигурации в C# не нужно, вместо cont_args_def можно просто использовать стандартные параметры, получаемые по выводу ps_args.<br>
<br>
ps_decode_raw больше нет в последних версиях pocketsphinx, потому что получить в C# и других языках правильный указатель на файл невозможно. Лучше читать данные из файла в C# буффер за буффером и передавать их в ps_process_raw. Этот метод отражён в последнем руководстве по pocketsphinx:<br>
<br>
<a class='tag-url' href='http://cmusphinx.sourceforge.net/wiki/tutorialpocketsphinx' target='_blank'>http://cmusphinx.sourceforge.net/wiki/tutorialpocketsphinx</a><br>
<br>
Часто не очень удобно оборачивать сложные функции pocketsphinx в вызовы C#. Чтобы упростить работу можно сделать функцию в C с простыми аргументами и вызывать её из C#. Например, как тут:<br>
<br>
<a class='tag-url' href='https://sourceforge.net/p/cmusphinx/discussion/help/thread/a11f4e27/' target='_blank'>https://sourceforge.net/p/cmusphinx/discuss...hread/a11f4e27/</a><br>
<br>
<a class='tag-url' href='https://sourceforge.net/p/cmusphinx/discussion/help/thread/a11f4e27/75a8/attachment/mymodule.h' target='_blank'>https://sourceforge.net/p/cmusphinx/discuss...ment/mymodule.h</a><br>
<a class='tag-url' href='https://sourceforge.net/p/cmusphinx/discussion/help/thread/a11f4e27/75a8/attachment/mymodule.c' target='_blank'>https://sourceforge.net/p/cmusphinx/discuss...ment/mymodule.c</a><br>
<a class='tag-url' href='https://sourceforge.net/p/cmusphinx/discussion/help/thread/a11f4e27/82e7/attachment/cs_and_so.zip' target='_blank'>https://sourceforge.net/p/cmusphinx/discuss...t/cs_and_so.zip</a>]]></description>
        <author>nsh</author>
        <category>Речевые Технологии</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=404097&amp;view=findpost&amp;p=3612319</guid>
        <pubDate>Sun, 12 Jul 2015 15:00:52 +0000</pubDate>
        <title>Подключение PocketSphinx к C#</title>
        <link>https://forum.sources.ru/index.php?showtopic=404097&amp;view=findpost&amp;p=3612319</link>
        <description><![CDATA[paulboxer: Я понял что к References dll подключать не надо.<br>
Теперь застрял на том как передать в библиотеку структуру arg_t которая описывается в той же длл...  :wall: <br>
<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">using System;</div><div class="code_line">using System.Collections.Generic;</div><div class="code_line">using System.Linq;</div><div class="code_line">using System.Text;</div><div class="code_line">using System.Threading.Tasks;</div><div class="code_line">using System.Runtime.InteropServices;</div><div class="code_line">&nbsp;</div><div class="code_line">namespace callsphinx</div><div class="code_line">{ &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;class Program</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;//ps_decoder_t* ps_init(cmd_ln_t* config)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;[DllImport(&quot;pocketsphinx.dll&quot;,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SetLastError = true,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CallingConvention = CallingConvention.Cdecl)]</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;public extern static IntPtr ps_init(</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;IntPtr config);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;//int ps_decode_raw(ps_decoder_t *ps, FILE *rawfh, char const *uttid, long maxsamps);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;[DllImport(&quot;pocketsphinx.dll&quot;,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SetLastError = true,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CallingConvention = CallingConvention.Cdecl)]</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;public extern static int ps_decode_raw(</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;IntPtr ps,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;IntPtr rawfh,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[MarshalAs(UnmanagedType.LPStr)] string uttid,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;int maxsamps);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;[DllImport(&quot;msvcrt.dll&quot;,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SetLastError = true,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CallingConvention = CallingConvention.Cdecl)]</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;public extern static IntPtr fopen(</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[MarshalAs(UnmanagedType.LPStr)] string _Filename,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[MarshalAs(UnmanagedType.LPStr)] string _Mode);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;//SPHINXBASE_EXPORT cmd_ln_t* cmd_ln_parse_r &nbsp; &nbsp;( &nbsp; cmd_ln_t * &nbsp;inout_cmdln,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;// &nbsp; &nbsp;arg_t const * &nbsp; &nbsp; defn, - как эту структуру описать?</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;// &nbsp; &nbsp;int32 &nbsp; &nbsp; argc,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;// &nbsp; &nbsp;char * &nbsp; &nbsp;argv[],</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;// &nbsp; &nbsp;int32 &nbsp; &nbsp; strict </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;// &nbsp; &nbsp;) &nbsp; &nbsp; </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;[DllImport(&quot;sphinxbase.dll&quot;,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SetLastError = true,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CallingConvention = CallingConvention.Cdecl)]</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;public extern static IntPtr cmd_ln_parse_r(/*Надо придумать как сдесь 5 параметров описать...*/);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;static void Main(int argc, string[] args)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//char *argv[]; - код из &quot;Си&quot;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;IntPtr config = cmd_ln_parse_r(null, cont_args_def, argc, argv, true); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;IntPtr ps = ps_init(config);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;IntPtr fh = fopen(@&quot;goforward.raw&quot;, &quot;rb&quot;);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;int rv = ps_decode_raw(ps, fh, &quot;goforward&quot;, -1);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">}</div></ol></div></div></div></div><script>preloadCodeButtons('1');</script><br>
<br>
описание структуры на &quot;Си&quot;...<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">/**</div><div class="code_line">&nbsp;* @struct arg_t</div><div class="code_line">&nbsp;* Argument definition structure.</div><div class="code_line">&nbsp;*/</div><div class="code_line">typedef struct arg_s {</div><div class="code_line">&nbsp;&nbsp; &nbsp;char const *name; &nbsp; /**&#60; Name of the command line switch */</div><div class="code_line">&nbsp;&nbsp; &nbsp;int type; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /**&#60; Type of the argument in question */</div><div class="code_line">&nbsp;&nbsp; &nbsp;char const *deflt; &nbsp;/**&#60; Default value (as a character string), or NULL if none */</div><div class="code_line">&nbsp;&nbsp; &nbsp;char const *doc; &nbsp; &nbsp;/**&#60; Documentation/description string */</div><div class="code_line">} arg_t;</div><div class="code_line">&nbsp;</div><div class="code_line">static const arg_t cont_args_def[] = {</div><div class="code_line">&nbsp;&nbsp; &nbsp;POCKETSPHINX_OPTIONS,</div><div class="code_line">&nbsp;&nbsp; &nbsp;/* Argument file. */</div><div class="code_line">&nbsp;&nbsp; &nbsp;{&quot;-argfile&quot;,</div><div class="code_line">&nbsp;&nbsp; &nbsp; ARG_STRING,</div><div class="code_line">&nbsp;&nbsp; &nbsp; NULL,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &quot;Argument file giving extra arguments.&quot;},</div><div class="code_line">&nbsp;&nbsp; &nbsp;{&quot;-adcdev&quot;,</div><div class="code_line">&nbsp;&nbsp; &nbsp; ARG_STRING,</div><div class="code_line">&nbsp;&nbsp; &nbsp; NULL,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &quot;Name of audio device to use for input.&quot;},</div><div class="code_line">&nbsp;&nbsp; &nbsp;{&quot;-infile&quot;,</div><div class="code_line">&nbsp;&nbsp; &nbsp; ARG_STRING,</div><div class="code_line">&nbsp;&nbsp; &nbsp; NULL,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &quot;Audio file to transcribe.&quot;},</div><div class="code_line">&nbsp;&nbsp; &nbsp;{&quot;-inmic&quot;,</div><div class="code_line">&nbsp;&nbsp; &nbsp; ARG_BOOLEAN,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &quot;no&quot;,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &quot;Transcribe audio from microphone.&quot;},</div><div class="code_line">&nbsp;&nbsp; &nbsp;{&quot;-time&quot;,</div><div class="code_line">&nbsp;&nbsp; &nbsp; ARG_BOOLEAN,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &quot;no&quot;,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &quot;Print word times in file transcription.&quot;},</div><div class="code_line">&nbsp;&nbsp; &nbsp;CMDLN_EMPTY_OPTION</div><div class="code_line">};</div></ol></div></div></div></div>]]></description>
        <author>paulboxer</author>
        <category>Речевые Технологии</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=404097&amp;view=findpost&amp;p=3612305</guid>
        <pubDate>Sun, 12 Jul 2015 13:41:43 +0000</pubDate>
        <title>Подключение PocketSphinx к C#</title>
        <link>https://forum.sources.ru/index.php?showtopic=404097&amp;view=findpost&amp;p=3612305</link>
        <description><![CDATA[paulboxer: PocketSphinx - открытое ПО для распознания речи, <a class='tag-url' href='http://cmusphinx.sourceforge.net/wiki/download' target='_blank'>http://cmusphinx.sourceforge.net/wiki/download</a> - исходники.  Есть две библиотеки pocketsphinx.dll и sphinxbase.dll, которые я хочу вызвать из C#.<br>
Нашел пример подобного использования <a class='tag-url' href='http://stackoverflow.com/questions/25900923/calling-pocketsphinx-in-c-sharp-accesviolationexception' target='_blank'>http://stackoverflow.com/questions/2590092...lationexception</a> <br>
но он обрезанный, нужны еще строки подключения библиотеки например: using pocketsphinx. Но как их подключить к проекту? Я пытался подключить через References и получил сообщение что сборка недопустима.  <br>
вот описание API:<br>
<a class='tag-url' href='http://cmusphinx.sourceforge.net/doc/pocketsphinx/index.html' target='_blank'>http://cmusphinx.sourceforge.net/doc/pocketsphinx/index.html</a><br>
<a class='tag-url' href='http://cmusphinx.sourceforge.net/doc/sphinxbase/index.html' target='_blank'>http://cmusphinx.sourceforge.net/doc/sphinxbase/index.html</a><br>
<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">&nbsp;&nbsp; &nbsp;</div><div class="code_line">using System;</div><div class="code_line">using System.Collections.Generic;</div><div class="code_line">using System.Linq;</div><div class="code_line">using System.Text;</div><div class="code_line">using System.Threading.Tasks;</div><div class="code_line">using System.Runtime.InteropServices;</div><div class="code_line">&nbsp;</div><div class="code_line">namespace callsphinx</div><div class="code_line">{ &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;class Program</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;//ps_decoder_t* ps_init(cmd_ln_t* config)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;[DllImport(&quot;pocketsphinx.dll&quot;,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SetLastError = true,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CallingConvention = CallingConvention.Cdecl)]</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;public extern static IntPtr ps_init(</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;IntPtr config);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;//int ps_decode_raw(ps_decoder_t *ps, FILE *rawfh, char const *uttid, long maxsamps);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;[DllImport(&quot;pocketsphinx.dll&quot;,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SetLastError = true,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CallingConvention = CallingConvention.Cdecl)]</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;public extern static int ps_decode_raw(</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;IntPtr ps,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;IntPtr rawfh,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[MarshalAs(UnmanagedType.LPStr)] string uttid,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;int maxsamps);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;[DllImport(&quot;msvcrt.dll&quot;,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SetLastError = true,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CallingConvention = CallingConvention.Cdecl)]</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;public extern static IntPtr fopen(</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[MarshalAs(UnmanagedType.LPStr)] string _Filename,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[MarshalAs(UnmanagedType.LPStr)] string _Mode); &nbsp; &nbsp; &nbsp; </div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;static void Main(string[] args)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;IntPtr ps = PocketSphinx.ps_init(config);//PocketSphinx - не существует в текущем контексте, как его подключить?</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;IntPtr fh = Win32Util.fopen(@&quot;goforward.raw&quot;, &quot;rb&quot;);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;int rv = PocketSphinx.ps_decode_raw(ps, fh, &quot;goforward&quot;, -1);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">}</div></ol></div></div></div></div><br>
<span class="b-attach" data-size="64520" data-hits="935" data-attach-id="45851" data-attach-post-id="3612305">
			<span class="b-attach__title"></span><a class='b-attach-link' href='https://forum.sources.ru/index.php?act=Attach&amp;type=post&amp;id=3612305&amp;attach_id=45851' title='Скачать файл' target='_blank'>___________________________________.png</a> (, : 935)
		</span>]]></description>
        <author>paulboxer</author>
        <category>Речевые Технологии</category>
      </item>
	
      </channel>
      </rss>
	