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.38k stars 1.04k forks source link

Vosk KeyPhrase Problem not working for arabic (Unity) #1446

Open ehabtawfikelbwab opened 9 months ago

ehabtawfikelbwab commented 9 months ago

Hi There,

I'm using vosk sdk for unity and working fine just for english

i have different users with different custom words i did use KeyPhrase feature on english and it working great. but when i use it on arabic model it did not working

can you help me please to make KeyPhrase feature on arabic ?

i did try both of two arabic models and it not working https://alphacephei.com/vosk/models

nshmyrev commented 9 months ago

Try this one:

https://alphacephei.com/vosk/models/vosk-model-small-ar-0.3.zip

ehabtawfikelbwab commented 9 months ago

not working :( english working good

ehabtawfikelbwab commented 9 months ago

i'm using this audio file : http://sndup.net/spg2

and i'm using this code to transform .wav (audioClip) to short[]

` public static short[] AudioClipToShortArray(AudioClip audioClip) { // Check if the AudioClip is null if (audioClip == null) { Debug.LogError("AudioClip is null."); return null; }

    // Calculate the number of samples in the AudioClip
    int numSamples = audioClip.samples * audioClip.channels;

    // Create a float array to hold the audio data
    float[] audioData = new float[numSamples];

    // Get the audio data from the AudioClip and store it in the float array
    audioClip.GetData(audioData, 0);

    // Create a short array to hold the converted audio data
    short[] shortData = new short[numSamples];

    // Convert the float data to short data
    for (int i = 0; i < numSamples; i++)
    {
        shortData[i] = (short)(audioData[i] * short.MaxValue);
    }

    return shortData;
}`

i'm using this code to send Audio Data to recognizer:

`        if (_recognizer.AcceptWaveform(Full_data, Full_data.Length))
    {
        var result = _recognizer.Result();
        _threadedResultQueue.Enqueue(result);
        print(result);
    }
    else
    {
        print("Failed");
    }`

when Initializing the english model and doing AudioClip to short[] and run it by the previous code 
the result is: "Ehab" and that very correct also i did use another custom words and working fine 

when Initializing the arabic model and doing the same steps it not working at all

its print "Failed" that mean the Waveform not Accepted also i did try different words and the same result the result should be "ايهاب"

i'm using keyPharse feature and the arabic keyPharse list contain "ايهاب" and english keyPharse list contain "ehab"

ehabtawfikelbwab commented 8 months ago

@nshmyrev are you there sir