Menu

how to create a C# wrapper for pocketsphinx

Help
vivian
2018-10-30
2019-06-15
  • vivian

    vivian - 2018-10-30

    Hi! I'm trying include pocketsphinx in my C# project as speech-to-text function using Visual Studio.
    1. Should I create wrapper using SWIG, it there any official tool for it?
    2. I read the tutorial here https://cmusphinx.github.io/wiki/tutorialpocketsphinx/#pocketsphinx-api-core-ideas
    but is the API available on Win10 and can I just directly include the code on VS C# project?
    3. I also downloaded the folder for C# here https://github.com/cmusphinx/pocketsphinx/tree/master/swig/csharp can I use the test.cs file for C# project?

    Thank you very much! Appreciate your help!!

     
    • Nickolay V. Shmyrev

      You can start with learning about swig first and trying simple swig examples:

      https://www.technical-recipes.com/2013/getting-started-with-swig-interfacing-between-c-and-c-visual-studio-projects/

      Then you can proceed with porting makefile from https://github.com/cmusphinx/pocketsphinx/tree/master/swig/csharp to Windows nmake to compile pocketsphinx dll for C# and then you can use it in c# as demonstrated in test.cs from the same folder.

       
      • vivian

        vivian - 2018-11-10

        Thanks Nickolay
        I am following the link you gave me. And I'm trying to port the makefile but it return this error

        mkdir -p gen
                swig -I.. -I../../../sphinxbase/swig -I../include -I../../sphinxbase/include  -csharp  -dllimport "libpocketsphinxwrap.so"  -namespace "Pocketsphinx" -o sphinxbase.c  -outdir gen ../../../sphinxbase/swig/sphinxbase.i
        'swig' is not recognized as an internal or external command,
        operable program or batch file.
        NMAKE : fatal error U1077: 'swig' : return code '0x1'
        Stop.
        
         
        • vivian

          vivian - 2018-11-10

          I solved the above error but another problems occur when it's running this line

          gcc -fPIC `pkg-config --libs --cflags pocketsphinx` pocketsphinx.c sphinxbase.c -shared -o libpocketsphinxwrap.so
          
          gcc: error: 'pkg-config: No such file or directory
          gcc: error: pocketsphinx': No such file or directory
          gcc: error: unrecognized command line option '--libs'
          gcc: error: unrecognized command line option '--cflags'
          
           

          Last edit: vivian 2018-11-10
  • waleed.makarem

    waleed.makarem - 2019-06-15

    Hi Vivian,
    I am facing same issue. Are you able to port sphinx to C# ?
    Thanks.
    Waleed

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.