alphacep / vosk-api

Offline speech recognition API for Android, iOS, Raspberry Pi and servers with Python, Java, C# and Node
Apache License 2.0
7.37k stars 1.04k forks source link

want to compile the vosk-api for arm64 #1477

Closed 8rabbit closed 6 months ago

8rabbit commented 6 months ago

I want to compile the vosk-api for aarch64. I have aboard which have arm64 processor and i have also arm64 tool chain for cross-compilation. I wrote the c code for running the application below but unfortunately, i cant do the cross-compile and can't generate the libvosk.so for arm64.

include

include

include

include

include

define SAMPLE_RATE 16000

define FRAME_SIZE 256

int main() { const char model_path = "Replace with your model path"; VoskModel model = vosk_model_new(model_path); VoskRecognizer *recognizer = vosk_recognizer_new(model, SAMPLE_RATE); PaError err; err = Pa_Initialize(); if (err != paNoError) { fprintf(stderr, "PortAudio error: %s\n", Pa_GetErrorText(err)); return 1; }

PaStream *stream;
PaStreamParameters inputParameters;
inputParameters.device = Pa_GetDefaultInputDevice();
inputParameters.channelCount = 1;
inputParameters.sampleFormat = paInt16;
inputParameters.suggestedLatency = Pa_GetDeviceInfo(inputParameters.device)->defaultLowInputLatency;
inputParameters.hostApiSpecificStreamInfo = NULL;

err = Pa_OpenStream(&stream, &inputParameters, NULL, SAMPLE_RATE, FRAME_SIZE, paClipOff, NULL, NULL);
if (err != paNoError)
{
    fprintf(stderr, "PortAudio error: %s\n", Pa_GetErrorText(err));
    Pa_Terminate();
    return 1;
}

err = Pa_StartStream(stream);
if (err != paNoError)
{
    fprintf(stderr, "PortAudio error: %s\n", Pa_GetErrorText(err));
    Pa_CloseStream(stream);
    Pa_Terminate();
    return 1;
}

short buf[FRAME_SIZE];
while (1)
{
    if (Pa_ReadStream(stream, buf, FRAME_SIZE) != paNoError)
    {
        fprintf(stderr, "Error reading stream\n");
        break;
    }

    char data[FRAME_SIZE * sizeof(short)];
    for (int i = 0; i < FRAME_SIZE; ++i)
    {
        data[i * sizeof(short)] = buf[i] & 0xFF;            // Least significant byte
        data[i * sizeof(short) + 1] = (buf[i] >> 8) & 0xFF; // Most significant byte
    }

    if (vosk_recognizer_accept_waveform(recognizer, data, FRAME_SIZE * sizeof(short)) != 0)
    {
        const char *result = vosk_recognizer_result(recognizer);
        // printf("%s\n", result); // Print recognized text
        if (result != NULL)
        {
            int len = strlen(result);
            if (len > 17)
            { // Check if the length is long enough to apply slicing [14:-3]
                printf("%.*s\n", len - 3 - 14, result + 14);
            }
        }
    }
}

Pa_StopStream(stream);
Pa_CloseStream(stream);
vosk_recognizer_free(recognizer);
vosk_model_free(model);
Pa_Terminate();

return 0;

}

so after searching for a month, i got to know that there is some docker and some wheels file but i got know using wheel how to compile my c code and last is docker file for arm64 but got a error i cant find any solution.. actually vosk-api is a really good api i want to use for continuous voice-to-text conversion. i compiled for my linux x86 64 it is working fine but for arm64 i cant even compile please give me any solution..

nshmyrev commented 6 months ago

how to compile my c code

With device-specific SDK

but got a error i cant find any solution

which error exactly?

You need to be more specific about your question, right now it is too broad, it is hard to answer.

8rabbit commented 6 months ago

actually sir my board is polis-imx8mm which is a arm64 processor based computer. I wrote the above code using chatGPT for offline continious voice -to-text conversion. for that I have used your documentation for use vosk-api. First i compiled with linux x86_64 but now i want to compile the same with my arm64. i have tried many things but some where i got the compiled libvosk.so in https://aur.archlinux.org/packages/vosk-api-bin website and got the compiled libvosk.so so from their only i have used the libvosk and after that i compiled by activating my own board toolchain

${CC} -o /home/phytec/vosk_voice_text/vosk_recog_temp /home/phytec/vosk_voice_text/vosk_recog_temp.c -L /home/phytec/Downloads/vosk-linux-aarch64-0.3.45 -I /home/phytec/Downloads/vosk-linux-aarch64-0.3.45 -L /opt/ampliphy-vendor-xwayland/BSP-Yocto-NXP-i.MX8MM-PD22.1.0/sysroots/cortexa53-crypto-phytec-linux/usr/lib -lvosk /opt/ampliphy-vendor-xwayland/BSP-Yocto-NXP-i.MX8MM-PD22.1.0/sysroots/cortexa53-crypto-phytec-linux/usr/lib/libportaudio.so.2.0.0 -lpthread

and it successfully compiled my c code which i have given you before but while i try to run that binary file in my arm64 polis-imx8mm the below error i got

root@polis-imx8mm-4:speech-text# ./vosk_recog_temp LOG (VoskAPI:ReadDataFiles():model.cc:213) Decoding params beam=10 max-active=3000 lattice-beam=2 LOG (VoskAPI:ReadDataFiles():model.cc:216) Silence phones 1:2:3:4:5:6:7:8:9:10 LOG (VoskAPI:RemoveOrphanNodes():nnet-nnet.cc:948) Removed 1 orphan nodes. LOG (VoskAPI:RemoveOrphanComponents():nnet-nnet.cc:847) Removing 2 orphan components. LOG (VoskAPI:Collapse():nnet-utils.cc:1488) Added 1 components, removed 2 LOG (VoskAPI:ReadDataFiles():model.cc:248) Loading i-vector extractor from /lib/vosk-model-small-en-in-0.4/ivector/final.ie LOG (VoskAPI:ComputeDerivedVars():ivector-extractor.cc:183) Computing derived variables for iVector extractor LOG (VoskAPI:ComputeDerivedVars():ivector-extractor.cc:204) Done. LOG (VoskAPI:ReadDataFiles():model.cc:282) Loading HCL and G from /lib/vosk-model-small-en-in-0.4/graph/HCLr.fst /lib/vosk-model-small-en-in-0.4/graph/Gr.fst [ 33.758082] mipi_1p0: disabling [ 33.761240] usb_otg1_vbus: disabling LOG (VoskAPI:ReadDataFiles():model.cc:308) Loading winfo /lib/vosk-model-small-en-in-0.4/graph/phones/word_boundary.int ALSA lib ../../alsa-lib-1.2.4/src/confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.Dummy.pcm.front.0:CARD=0' ALSA lib ../../alsa-lib-1.2.4/src/conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib ../../alsa-lib-1.2.4/src/conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory ALSA lib ../../../alsa-lib-1.2.4/src/pcm/pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM front ALSA lib ../../../alsa-lib-1.2.4/src/pcm/pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear ALSA lib ../../../alsa-lib-1.2.4/src/pcm/pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe ALSA lib ../../../alsa-lib-1.2.4/src/pcm/pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side ALSA lib ../../alsa-lib-1.2.4/src/confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.Dummy.pcm.surround51.0:CARD=0' ALSA lib ../../alsa-lib-1.2.4/src/conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib ../../alsa-lib-1.2.4/src/conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory ALSA lib ../../../alsa-lib-1.2.4/src/pcm/pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM surround21 ALSA lib ../../alsa-lib-1.2.4/src/confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.Dummy.pcm.surround51.0:CARD=0' ALSA lib ../../alsa-lib-1.2.4/src/conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib ../../alsa-lib-1.2.4/src/conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory ALSA lib ../../../alsa-lib-1.2.4/src/pcm/pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM surround21 ALSA lib ../../alsa-lib-1.2.4/src/confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.Dummy.pcm.surround40.0:CARD=0' ALSA lib ../../alsa-lib-1.2.4/src/conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib ../../alsa-lib-1.2.4/src/conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory ALSA lib ../../../alsa-lib-1.2.4/src/pcm/pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM surround40 ALSA lib ../../alsa-lib-1.2.4/src/confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.Dummy.pcm.surround51.0:CARD=0' ALSA lib ../../alsa-lib-1.2.4/src/conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib ../../alsa-lib-1.2.4/src/conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory ALSA lib ../../../alsa-lib-1.2.4/src/pcm/pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM surround41 ALSA lib ../../alsa-lib-1.2.4/src/confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.Dummy.pcm.surround51.0:CARD=0' ALSA lib ../../alsa-lib-1.2.4/src/conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib ../../alsa-lib-1.2.4/src/conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory ALSA lib ../../../alsa-lib-1.2.4/src/pcm/pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM surround50 ALSA lib ../../alsa-lib-1.2.4/src/confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.Dummy.pcm.surround51.0:CARD=0' ALSA lib ../../alsa-lib-1.2.4/src/conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib ../../alsa-lib-1.2.4/src/conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory ALSA lib ../../../alsa-lib-1.2.4/src/pcm/pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM surround51 ALSA lib ../../alsa-lib-1.2.4/src/confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.Dummy.pcm.surround71.0:CARD=0' ALSA lib ../../alsa-lib-1.2.4/src/conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib ../../alsa-lib-1.2.4/src/conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory ALSA lib ../../../alsa-lib-1.2.4/src/pcm/pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM surround71 ALSA lib ../../alsa-lib-1.2.4/src/confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.Dummy.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2' ALSA lib ../../alsa-lib-1.2.4/src/conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib ../../alsa-lib-1.2.4/src/conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory ALSA lib ../../../alsa-lib-1.2.4/src/pcm/pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM iec958 ALSA lib ../../alsa-lib-1.2.4/src/confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.Dummy.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2' ALSA lib ../../alsa-lib-1.2.4/src/conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib ../../alsa-lib-1.2.4/src/conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory ALSA lib ../../../alsa-lib-1.2.4/src/pcm/pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM spdif ALSA lib ../../alsa-lib-1.2.4/src/confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.Dummy.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2' ALSA lib ../../alsa-lib-1.2.4/src/conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib ../../alsa-lib-1.2.4/src/conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory ALSA lib ../../../alsa-lib-1.2.4/src/pcm/pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM spdif ALSA lib ../../../alsa-lib-1.2.4/src/pcm/pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi ALSA lib ../../../alsa-lib-1.2.4/src/pcm/pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi ALSA lib ../../../alsa-lib-1.2.4/src/pcm/pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem ALSA lib ../../../alsa-lib-1.2.4/src/pcm/pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem ALSA lib ../../../alsa-lib-1.2.4/src/pcm/pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline ALSA lib ../../../alsa-lib-1.2.4/src/pcm/pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline ALSA lib ../../../alsa-lib-1.2.4/src/pcm/pcm_dmix.c:1009:(snd_pcm_dmix_open) The dmix plugin supports only playback stream ALSA lib ../../../alsa-lib-1.2.4/src/pcm/pcm_dmix.c:1075:(snd_pcm_dmix_open) unable to open slave ALSA lib ../../../alsa-lib-1.2.4/src/pcm/pcm_dsnoop.c:638:(snd_pcm_dsnoop_open) unable to open slave ALSA lib ../../../alsa-lib-1.2.4/src/pcm/pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM dummy ALSA lib ../../../alsa-lib-1.2.4/src/pcm/pcm_dmix.c:1075:(snd_pcm_dmix_open) unable to open slave ALSA lib ../../../alsa-lib-1.2.4/src/pcm/pcm_dsnoop.c:638:(snd_pcm_dsnoop_open) unable to open slave ALSA lib ../../../alsa-lib-1.2.4/src/pcm/pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM dummy Cannot connect to server socket err = No such file or directory Cannot connect to server request channel jack server is not running or cannot be started JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock Error reading stream root@polis-imx8mm-4:speech-text#

i cant understand what to do next i cant further proceed please help me out from this error.

8rabbit commented 6 months ago

i have use this zip file https://github.com/alphacep/vosk-api/releases/download/v0.3.45/vosk-linux-aarch64-0.3.45.zip for the libvosk.so and vosk_api.h

or if you have any other procedure for offline continious voice-to-text conversion please tell me... i got stucked...

nshmyrev commented 6 months ago

From the log vosk compiled and runs fine, you only have portaudio problems. You can configure alsa on the device to make sure portaudio works. You can use alsa command line tools like arecord to make sure alsa works.

It is also better to use alsa API directly instead of portaudio.

8rabbit commented 6 months ago

I have change some code for taking input

include

include

include

include

include

define SAMPLE_RATE 16000

define FRAME_SIZE 256

void printDeviceList() { int numDevices = Pa_GetDeviceCount(); if (numDevices <= 0) { fprintf(stderr, "No input devices found.\n"); return; }

printf("Available input devices:\n");
for (int i = 0; i < numDevices; ++i) {
    const PaDeviceInfo *deviceInfo = Pa_GetDeviceInfo(i);
    printf("Input Device #%d: %s\n", i, deviceInfo->name);
}

}

int main() { const char model_path = "/lib/vosk-model-small-en-in-0.4"; // Replace with your model path VoskModel model = vosk_model_new(model_path); VoskRecognizer *recognizer = vosk_recognizer_new(model, SAMPLE_RATE); PaError err;

err = Pa_Initialize();
if (err != paNoError) {
    fprintf(stderr, "PortAudio error: %s\n", Pa_GetErrorText(err));
    return 1;
}

printDeviceList();

printf("\nEnter the index of the input device you want to use: ");
int chosenDevice;
if (scanf("%d", &chosenDevice) != 1) {
    fprintf(stderr, "Invalid input device index.\n");
    Pa_Terminate();
    return 1;
}

PaStream *stream;
PaStreamParameters inputParameters;
inputParameters.device = chosenDevice;
inputParameters.channelCount = 1;
inputParameters.sampleFormat = paInt16;
inputParameters.suggestedLatency = Pa_GetDeviceInfo(inputParameters.device)->defaultLowInputLatency;
inputParameters.hostApiSpecificStreamInfo = NULL;

err = Pa_OpenStream(&stream, &inputParameters, NULL, SAMPLE_RATE, FRAME_SIZE, paClipOff, NULL, NULL);
if (err != paNoError) {
    fprintf(stderr, "PortAudio error: %s\n", Pa_GetErrorText(err));
    Pa_Terminate();
    return 1;
}

err = Pa_StartStream(stream);
if (err != paNoError) {
    fprintf(stderr, "PortAudio error: %s\n", Pa_GetErrorText(err));
    Pa_CloseStream(stream);
    Pa_Terminate();
    return 1;
}

short buf[FRAME_SIZE];
while (1) {
    if (Pa_ReadStream(stream, buf, FRAME_SIZE) != paNoError) {
        fprintf(stderr, "Error reading stream\n");
        break;
    }

char data[FRAME_SIZE * sizeof(short)];
    for (int i = 0; i < FRAME_SIZE; ++i)
    {
        data[i * sizeof(short)] = buf[i] & 0xFF;            // Least significant byte
        data[i * sizeof(short) + 1] = (buf[i] >> 8) & 0xFF; // Most significant byte
    }

    if (vosk_recognizer_accept_waveform(recognizer, data, FRAME_SIZE * sizeof(short)) != 0)
    {
        const char *result = vosk_recognizer_result(recognizer);
        // printf("%s\n", result); // Print recognized text
        if (result != NULL)
        {
            int len = strlen(result);
            if (len > 17)
            { // Check if the length is long enough to apply slicing [14:-3]
                printf("%.*s\n", len - 3 - 14, result + 14);
            }
        }
    }
}

Pa_StopStream(stream);
Pa_CloseStream(stream);
vosk_recognizer_free(recognizer);
vosk_model_free(model);
Pa_Terminate();

return 0;

}

root@polis-imx8mm-4:speech-text# ./vosk_recog_arm64 LOG (VoskAPI:ReadDataFiles():model.cc:213) Decoding params beam=10 max-active=3000 lattice-beam=2 LOG (VoskAPI:ReadDataFiles():model.cc:216) Silence phones 1:2:3:4:5:6:7:8:9:10 LOG (VoskAPI:RemoveOrphanNodes():nnet-nnet.cc:948) Removed 1 orphan nodes. LOG (VoskAPI:RemoveOrphanComponents():nnet-nnet.cc:847) Removing 2 orphan components. LOG (VoskAPI:Collapse():nnet-utils.cc:1488) Added 1 components, removed 2 LOG (VoskAPI:ReadDataFiles():model.cc:248) Loading i-vector extractor from /lib/vosk-model-small-en-in-0.4/ivector/final.ie LOG (VoskAPI:ComputeDerivedVars():ivector-extractor.cc:183) Computing derived variables for iVector extractor LOG (VoskAPI:ComputeDerivedVars():ivector-extractor.cc:204) Done. LOG (VoskAPI:ReadDataFiles():model.cc:282) Loading HCL and G from /lib/vosk-model-small-en-in-0.4/graph/HCLr.fst /lib/vosk-model-small-en-in-0.4/graph/Gr.fst LOG (VoskAPI:ReadDataFiles():model.cc:308) Loading winfo /lib/vosk-model-small-en-in-0.4/graph/phones/word_boundary.int ALSA lib ../../alsa-lib-1.2.4/src/confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.Dummy.pcm.front.0:CARD=0' ALSA lib ../../alsa-lib-1.2.4/src/conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib ../../alsa-lib-1.2.4/src/conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory ALSA lib ../../../alsa-lib-1.2.4/src/pcm/pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM front ALSA lib ../../../alsa-lib-1.2.4/src/pcm/pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear ALSA lib ../../../alsa-lib-1.2.4/src/pcm/pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe ALSA lib ../../../alsa-lib-1.2.4/src/pcm/pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side ALSA lib ../../alsa-lib-1.2.4/src/confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.Dummy.pcm.surround51.0:CARD=0' ALSA lib ../../alsa-lib-1.2.4/src/conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib ../../alsa-lib-1.2.4/src/conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory ALSA lib ../../../alsa-lib-1.2.4/src/pcm/pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM surround21 ALSA lib ../../alsa-lib-1.2.4/src/confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.Dummy.pcm.surround51.0:CARD=0' ALSA lib ../../alsa-lib-1.2.4/src/conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib ../../alsa-lib-1.2.4/src/conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory ALSA lib ../../../alsa-lib-1.2.4/src/pcm/pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM surround21 ALSA lib ../../alsa-lib-1.2.4/src/confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.Dummy.pcm.surround40.0:CARD=0' ALSA lib ../../alsa-lib-1.2.4/src/conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib ../../alsa-lib-1.2.4/src/conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory ALSA lib ../../../alsa-lib-1.2.4/src/pcm/pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM surround40 ALSA lib ../../alsa-lib-1.2.4/src/confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.Dummy.pcm.surround51.0:CARD=0' ALSA lib ../../alsa-lib-1.2.4/src/conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib ../../alsa-lib-1.2.4/src/conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory ALSA lib ../../../alsa-lib-1.2.4/src/pcm/pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM surround41 ALSA lib ../../alsa-lib-1.2.4/src/confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.Dummy.pcm.surround51.0:CARD=0' ALSA lib ../../alsa-lib-1.2.4/src/conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib ../../alsa-lib-1.2.4/src/conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory ALSA lib ../../../alsa-lib-1.2.4/src/pcm/pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM surround50 ALSA lib ../../alsa-lib-1.2.4/src/confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.Dummy.pcm.surround51.0:CARD=0' ALSA lib ../../alsa-lib-1.2.4/src/conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib ../../alsa-lib-1.2.4/src/conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory ALSA lib ../../../alsa-lib-1.2.4/src/pcm/pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM surround51 ALSA lib ../../alsa-lib-1.2.4/src/confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.Dummy.pcm.surround71.0:CARD=0' ALSA lib ../../alsa-lib-1.2.4/src/conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib ../../alsa-lib-1.2.4/src/conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory ALSA lib ../../../alsa-lib-1.2.4/src/pcm/pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM surround71 ALSA lib ../../alsa-lib-1.2.4/src/confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.Dummy.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2' ALSA lib ../../alsa-lib-1.2.4/src/conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib ../../alsa-lib-1.2.4/src/conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory ALSA lib ../../../alsa-lib-1.2.4/src/pcm/pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM iec958 ALSA lib ../../alsa-lib-1.2.4/src/confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.Dummy.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2' ALSA lib ../../alsa-lib-1.2.4/src/conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib ../../alsa-lib-1.2.4/src/conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory ALSA lib ../../../alsa-lib-1.2.4/src/pcm/pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM spdif ALSA lib ../../alsa-lib-1.2.4/src/confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.Dummy.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2' ALSA lib ../../alsa-lib-1.2.4/src/conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib ../../alsa-lib-1.2.4/src/conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory ALSA lib ../../../alsa-lib-1.2.4/src/pcm/pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM spdif ALSA lib ../../../alsa-lib-1.2.4/src/pcm/pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi ALSA lib ../../../alsa-lib-1.2.4/src/pcm/pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi ALSA lib ../../../alsa-lib-1.2.4/src/pcm/pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem ALSA lib ../../../alsa-lib-1.2.4/src/pcm/pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem ALSA lib ../../../alsa-lib-1.2.4/src/pcm/pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline ALSA lib ../../../alsa-lib-1.2.4/src/pcm/pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline ALSA lib ../../../alsa-lib-1.2.4/src/pcm/pcm_dmix.c:1009:(snd_pcm_dmix_open) The dmix plugin supports only playback stream ALSA lib ../../../alsa-lib-1.2.4/src/pcm/pcm_dmix.c:1009:(snd_pcm_dmix_open) The dmix plugin supports only playback stream ALSA lib ../../../alsa-lib-1.2.4/src/pcm/pcm_dmix.c:1075:(snd_pcm_dmix_open) unable to open slave Cannot connect to server socket err = No such file or directory Cannot connect to server request channel jack server is not running or cannot be started JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock Available input devices: Input Device #0: Dummy: PCM (hw:0,0) Input Device #1: imx-audio-micfil: micfil hifi snd-soc-dummy-dai-0 (hw:1,0) Input Device #2: UACDemoV1.0: USB Audio (hw:2,0) Input Device #3: sysdefault Input Device #4: pulse Input Device #5: dummy Input Device #6: asymed Input Device #7: dmix Input Device #8: default

Enter the index of the input device you want to use: 4 hello hello ask hi hi ask keyboard i have a keyboard do you want

the above is one usb mic and it is working fine but while i try with my own mic

Available input devices: Input Device #0: Dummy: PCM (hw:0,0) Input Device #1: imx-audio-micfil: micfil hifi snd-soc-dummy-dai-0 (hw:1,0) Input Device #2: sysdefault Input Device #3: pulse Input Device #4: dummy Input Device #5: asymed Input Device #6: dmix Input Device #7: default

Enter the index of the input device you want to use: 1 Error reading stream root@polis-imx8mm-4:

and the above one i tried for my imx-audio-micfil: micfil hifi snd-soc-dummy-dai-0 (hw:1,0) device which is showing the above error, i have mentioed the below debug error print in the above code. the above whole code i took from chatGPT so i am not that much comfort to the code

short buf[FRAME_SIZE];
while (1) {
    if (Pa_ReadStream(stream, buf, FRAME_SIZE) != paNoError) {
        fprintf(stderr, "Error reading stream\n");
        break;
    }

Actually i have added this above mic into my device tree as below

&micfil {

    pinctrl-names = "default";

    pinctrl-0 = <&pinctrl_pdm>;

    assigned-clocks = <&clk IMX8MM_CLK_PDM>;

    assigned-clock-parents = <&clk IMX8MM_AUDIO_PLL1_OUT>;

    assigned-clock-rates = <196608000>;

    status = "okay";

};

the above configuration is working for my friend who is also working with the above device but he is not using the portaudio library for voice input i don't know anything how i will do this as you told before about ALSA configure and ALSA API, i never did any work using port audio and ALSA can you help me out sir because i don't have any idea about these ..

I dont have any idea i only want the code for voice-to-text conversion, if any issue with the above code can you share me any idea by which i can easily compile any c code in arm64 and use the binary to the linux arm64 system. I know sir you have ever did this.. please help me to come from this issue .

8rabbit commented 6 months ago

what i got to understand from the above that their is no issue with the imx-audio-micfil: micfil hifi snd-soc-dummy-dai-0 (hw:1,0) mic, might be any ALSA lib dependency like up gradation or anything else or the code i have written

see the belows are the alsa library in my arm64 system

root@polis-imx8mm-4:/# find -iname "alsa"
./run/systemd/units/invocation:alsa-restore.service ./usr/sbin/alsa-info.sh ./usr/sbin/alsactl ./usr/sbin/alsaconf ./usr/sbin/alsabat-test.sh ./usr/share/pulseaudio/alsa-mixer ./usr/share/zoneinfo/Asia/Choibalsan ./usr/share/zoneinfo/posix/Asia/Choibalsan ./usr/share/zoneinfo/right/Asia/Choibalsan ./usr/share/locale/de/LC_MESSAGES/alsa-utils.mo ./usr/share/locale/fr/LC_MESSAGES/alsa-utils.mo ./usr/share/sounds/alsa ./usr/share/alsa ./usr/share/alsa/alsa.conf ./usr/share/alsa/alsa.conf.d ./usr/bin/alsamixer ./usr/bin/alsatplg ./usr/bin/alsabat ./usr/bin/alsaloop ./usr/bin/alsaucm ./usr/lib/gstreamer-1.0/libgstalsa.so ./usr/lib/plugins/audio/libqtaudio_alsa.so ./usr/lib/alsa-lib ./usr/lib/pulse-14.2/modules/libalsa-util.so ./usr/lib/pulse-14.2/modules/module-alsa-sink.so ./usr/lib/pulse-14.2/modules/module-alsa-card.so ./usr/lib/pulse-14.2/modules/module-alsa-source.so ./usr/lib/ao/plugins-4/libalsa.so ./etc/alsa ./lib/modules/5.10.72-bsp-yocto-nxp-i.mx8mm-pd22.1.0/kernel/crypto/salsa20_generic.ko ./lib/modules/5.10.72/kernel/crypto/salsa20_generic.ko ./lib/systemd/system/sound.target.wants/alsa-state.service ./lib/systemd/system/sound.target.wants/alsa-restore.service ./lib/systemd/system/alsa-state.service ./lib/systemd/system/alsa-restore.service ./lib/udev/rules.d/60-persistent-alsa.rules ./lib/udev/rules.d/90-alsa-restore.rules ./var/lib/alsa

nshmyrev commented 6 months ago

You'd better use alsa directly like your friend, I told you, not portaudio.

All alsa errors above, they must be fixed with proper asound.conf, either systemwide or user-specific asoundrc.

8rabbit commented 6 months ago

So you mean portaudio have no dependency with ALSA?? Ok sir no issue I can use ALSA directly instade of portaudio but don't know how to use ALSA and what is this "asound.conf, either systemwide or user-specific asoundrc" ? Would you you like to tell me how to do the configuration in asound.conf and where is it ? Sir

8rabbit commented 6 months ago

thanks i have used ALSA for input voice and i have used your dockerfile for compiling the souce for arch64. thank you so much.. its working with great out accuracy is like 90-95 % or above ... i cant imagine its a offline machine ... @nshmyrev thank you very much.