Code Monkey home page Code Monkey logo

Comments (2)

AshleyF avatar AshleyF commented on May 14, 2024

It looks like perhaps the device doesn't support single-channel. The AudioCapture component takes an optional AudioCaptureConfiguration with a WaveFormat which defaults to 16KHz, 1 channel, 16-bit PCM. You could try passing a config with different settings.

I'm not sure how to query the hardware for this, but one possible way would be to record a clip with arecord and then look at file details with mediainfo which does show the sampling rate, channel count, etc.

from psi.

CobraCalle avatar CobraCalle commented on May 14, 2024

I think you are pointing in the right direction...
respeaker@E3BC1:~$ arecord -Dhw:0,0 -f S16_LE -r 16000 -c 1 hello.wav
Recording WAVE 'hello.wav' : Signed 16 bit Little Endian, Rate 16000 Hz, Mono
arecord: set_params:1305: Channels count non available

When I use stereo, it works fine...
respeaker@E3BC1:~$ arecord -Dhw:0,0 -f S16_LE -r 16000 -c 2 hello.wav
Recording WAVE 'hello.wav' : Signed 16 bit Little Endian, Rate 16000 Hz, Stereo
^CAborted by signal Interrupt...

But using two channels produces another error... but interestingly not an exception. it just prints "Seqmentation faul" to the console and stops...
respeaker@E3BC1:/mnt/Test$ ./ConsoleApp3
Please enter the device name
plughw:0,0
Please enter the sampling rate
16000
Please enter the channel count
2
Segmentation fault
respeaker@E3BC1:/mnt/Test$

Here is the code from my test app (xxx is a SimpleConsumer that does nothing else than printing a message to the console in "Receive"):
using (var pipeline = Microsoft.Psi.Pipeline.Create())
{
//var devices = AudioCapture.GetAvailableDevices();

            //foreach (var device in devices)
            //{
            //    Console.WriteLine(device);
            //}

            //Console.ReadLine();

            //audioCaptureConfiguration.OptimizeForSpeech = true;
            //audioCaptureConfiguration.OutputFormat = Microsoft.Psi.Audio.WaveFormat.Create16kHz1Channel16BitPcm();

            var audioCaptureConfiguration = new Microsoft.Psi.Audio.AudioCaptureConfiguration();

            Console.WriteLine("Please enter the device name");
            audioCaptureConfiguration.DeviceName = Console.ReadLine();

            Console.WriteLine("Please enter the sampling rate");
            var samplingRate = int.Parse(Console.ReadLine());

            Console.WriteLine("Please enter the channel count");
            var channelCount = int.Parse(Console.ReadLine());

            audioCaptureConfiguration.Format = Microsoft.Psi.Audio.WaveFormat.CreatePcm(samplingRate, 16, channelCount);

            using (var audioCapture = new Microsoft.Psi.Audio.AudioCapture(pipeline, audioCaptureConfiguration))
            {
                var audioInput = (Microsoft.Psi.IProducer<Microsoft.Psi.Audio.AudioBuffer>)audioCapture;

                audioInput.PipeTo(new xxx(pipeline));

                //pipeline.Run();

                using (pipeline.RunAsync())
                {
                    Console.ReadLine();
                }
            }
        }

What does Seqmentation fault mean?

Perhaps this could help...
https://stackoverflow.com/questions/48588513/segmentation-fault-in-alsa-capturing-example

from psi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.