Sidebar

en:objects:sound:sound_file:recognize_file_with_digits

recognize_file_with_digits

recognize_file_with_digits($path,$timeout=60); - recognize the audio file as speech consisting of English digits from 0 to 9) (Available from version 4.10.7)
- the audio file must have a resolution of 128 Kb/s (8 kHz) ( you can Change the file format via $sound->convert_file )

The input function accepts parameters:

  • $path – path to the audio file to be recognized
  • $timeout – maximum time allowed for this operation

    After testing , the function returns the result of its work to the script :
  • true – a sequence of numbers dictated in the audio file (separated by a space)
  • false – the operation was not completed successfully

    PHP example:

    <?php $xhe_host = "127.0.0.1:7010";
     
    //connect the object to control the emulator, if not already connected
    if(!isset($path))
      $path = "../../../Templates/xweb_human_emulator.php";
    require($path);
     
    //Start
    echo "<hr> <font color = blue> sound->".basename(__FILE__)."</font> <hr>";
     
    //1
    echo "1.Recognize the file with English numbers(0-9):";
    echo $sound->recognize_file_with_digits("test/mp3/4196092774.mp3")." n";
     
    //2
    echo "2.Recognize file with English numbers(0-9):";
    echo $sound->recognize_file_with_digits("test/mp3/80692.mp3")." n";
     
    //3
    echo "<center> <h5> Download file from Recaptcha V2 </h5> </center>";
    echo "3.Let's go to the polygon:";
    echo $browser->navigate("https://www.google.com/recaptcha/api2/demo")."<br>";
     
    //4
    echo "4.Click I'm not a robot:";
    while(!$div->get_by_attribute("class", "recaptcha-checkbox-checkmark", false, 0)->is_visibled()) sleep(1);
    echo $check = $div->get_by_attribute("class", "recaptcha-checkbox-checkmark", false, 0)->send_mouse_click(4,4)." n";
     
    //five
    echo "5.Let's press the audio version of the captcha:";
    while(!$btn->get_by_name("recaptcha-audio-button", 1)->is_visibled())
    {
    $div->get_by_attribute("class", "recaptcha-checkbox-checkmark", false, 0)->send_mouse_click(4,4);
    sleep(1);
    }
    echo $btn->get_by_name("recaptcha-audio-button", 1)->send_mouse_click(5,5)." n";
    sleep(4);
     
    //6
    echo "6.Click download:";
    $window->execute_download_file();
    $browser->set_default_download("download");
    $browser->enable_download_file_dialog(true);
    $file_os->delete("download/audio.mp3");
    while(!$anchor->get_by_href("api2/payload/audio.mp3", false, 1)->is_visibled())
    {
    $btn->get_by_name("recaptcha-audio-button", 1)->send_mouse_click(5,5)." n";
    sleep(1);
    }
    echo $anchor->get_by_href("api2/payload/audio.mp3", false, 1)->send_mouse_click(5,5)." n";
    sleep(3);
    //waiting for download
    while(!$file_os->is_exist("download/audio.mp3"))
      sleep(1);
     
     
    //7
    echo "7.Recognize file with English numbers(0-9):";
    echo $digits = $sound->recognize_file_with_digits("download/audio.mp3")."";
    sleep(1);
    if($digits == false)
    {
    echo "no audio file in correct format.(probably requesting audio file too often.Please try again later.)";
    $app->quit();
    }
     
    //8
    echo " n8.Enter the result:";
    $browser->set_active_browser(0);
    echo $input->get_by_name("audio-response", 1)->send_input($digits)." n";
    $btn->get_by_id("recaptcha-verify-button", false, 1)->send_mouse_click();
     
     
    //end
    echo "<hr> <br>";
     
    //Quit
    $app->quit();
    ?>

    Python example:

    # Additional paths
    import sys
    sys.path.insert(0, '../../../Templates PY/')
     
    xhe_host = "127.0.0.1:7010"
    from xweb_human_emulator import *
     
    # Start
    echo("<hr> <font color = blue> sound.xxxxxxxxx </font> <hr>")
     
    # 1
    echo("1.Recognize file with English numbers(0-9):")
    echo(sound.recognize_file_with_digits("test/mp3/4196092774.mp3"), "
    ")
     
    # 2
    echo("2.Recognize file with English numbers(0-9):")
    echo(sound.recognize_file_with_digits("test/mp3/80692.mp3"), "
    ")
     
    # 3
    echo("<center> <h5> Download file from Recaptcha V2 </h5> </center>")
    echo("3.Let's go to the polygon:")
    echo(browser.navigate("https://www.google.com/recaptcha/api2/demo"), "<br>")
     
    # 4
    echo("4.Click I'm not a robot:")
    while not div.get_by_attribute("class", "recaptcha-checkbox-checkmark", false, 0) .is_visibled():
        sleep(1)
     
    echo(div.get_by_attribute("class", "recaptcha-checkbox-checkmark", false, 0) .mouse_click(4,4), "
    ")
     
    # five
    echo("5.Press the audio version of the captcha:")
    while not btn.get_by_name("recaptcha-audio-button", 1) .is_visibled():
    div.get_by_attribute("class", "recaptcha-checkbox-checkmark", false, 0) .send_mouse_click(4,4)
    sleep(1)
     
    echo(btn.get_by_name("recaptcha-audio-button", 1) .send_mouse_click(5,5), "
    ")
    sleep(4)
     
    # 6
    echo("6.Click download:")
    window.execute_download_file()
    browser.set_default_download("download")
    browser.enable_download_file_dialog(true)
    file_os.delete("download/audio.mp3")
    while not anchor.get_by_href("api2/payload/audio.mp3", false, 1) .is_visibled():
    echo(btn.get_by_name("recaptcha-audio-button", 1) .send_mouse_click(5,5), "
    ")
    sleep(1)
     
    echo(anchor.get_by_href("api2/payload/audio.mp3", false, 1) .send_mouse_click(5,5), "
    ")
    sleep(3)
     
    # waiting for download
    while not file_os.is_exist("download/audio.mp3"):
      sleep(1)
     
    # 7
    echo("7.Recognize file with English numbers(0-9):")
    digits = sound.recognize_file_with_digits("download/audio.mp3")
    echo(digits)
    sleep(1)
    if digits == false:
    echo("no audio file in the correct format.(maybe requesting a sound file too often.please try again later.)")
    app.quit()
     
    # 8
    echo("
    8.Let's enter the result: ")
    browser.set_active_browser(0)
    echo(input.get_by_name("audio-response", 1) .send_input(digits), "
    ")
    btn.get_by_id("recaptcha-verify-button", false, 1) .send_mouse_click()
     
     
    # end
    echo("<hr> <br>")
     
    # Quit
    app.quit()

    C# example:

    #region using
     
    using System;
    using System.Diagnostics;
    using System.Collections.Generic;
    using System.Linq;
    using System.IO;
    using System.Text;
    using System.Threading;
     
    using XHE;
    using XHE.XHE_DOM;
    using XHE.XHE_System;
    using XHE.XHE_Window;
    using XHE.XHE_Web;
     
    #endregion
     
     class Program: XHEScript
     {
    static void Main(string [] args)
    {
    //init XHE
    server = "127.0.0.1:7020";
    InitXHE();
     
    //Start
    echo("<hr> <font color = blue> sound.recognize_file_with_digits </font> <hr>");
     
    //1
    echo("1.Recognize the file with English numbers(0-9):");
    echo(sound.recognize_file_with_digits("test/mp3/4196092774.mp3") + "
    ");
     
    //2
    echo("2.Recognize the file with English numbers(0-9):");
    echo(sound.recognize_file_with_digits("test/mp3/80692.mp3") + "
    ");
     
    //3
    echo("<center> <h5> Download the file from Recaptcha V2 </h5> </center>");
    echo("3.Let's go to the polygon:");
    echo(browser.navigate("https://www.google.com/recaptcha/api2/demo") + "<br>");
     
    //4
    echo("4.Click I'm not a robot:");
    while(!div.get_by_attribute("class", "recaptcha-checkbox-checkmark", false, "0").is_visibled()) sleep(1);
    echo(div.get_by_attribute("class", "recaptcha-checkbox-checkmark", false, "0").send_mouse_click(4,4) + "
    ");
     
    //five
    echo("5.Press the audio version of the captcha:");
    while(!btn.get_by_name("recaptcha-audio-button", "1").is_visibled())
    {
    div.get_by_attribute("class", "recaptcha-checkbox-checkmark", false, "0").send_mouse_click(4,4);
    sleep(1);
    }
    echo(btn.get_by_name("recaptcha-audio-button", "1").send_mouse_click(5,5) + "
    ");
    sleep(4);
     
    //6
    echo("6.Click download:");
    window.execute_download_file();
    browser.set_default_download("download");
    browser.enable_download_file_dialog(true);
    file_os.delete("download/audio.mp3");
    while(!anchor.get_by_href("api2/payload/audio.mp3", false, "1").is_visibled())
    {
    btn.get_by_name("recaptcha-audio-button", "1").send_mouse_click(5,5);
    sleep(1);
    }
    echo(anchor.get_by_href("api2/payload/audio.mp3", false, "1").send_mouse_click(5,5) + "
    ");
    sleep(3);
    //wait for download
    while(!file_os.is_exist("download/audio.mp3"))
    sleep(1);
     
     
    //7
    echo("7.Recognize the file with English numbers(0-9):");
    string digits = sound.recognize_file_with_digits("download/audio.mp3");
    echo(digits);
    sleep(1);
    if(digits == "false")
    {
    echo("There is no audio file in the correct format.(Perhaps we are requesting an audio file too often.Please try again later.)");
    app.quit();
    }
     
    //8
    echo("
    8.Let's enter the result: ");
    browser.set_active_browser(0);
    echo(input.get_by_name("audio-response", "1").send_input(digits) + "
    ");
    btn.get_by_id("recaptcha-verify-button", false, "1").send_mouse_click();
     
    //end
    echo("<hr> <br>");
     
    app.quit();
    }
    }

    Java Script example:

    //connect the object to control the emulator, if not already connected
    xhe_host = "127.0.0.1:7022";
    echo = require("../../../Templates JS/xweb_human_emulator.js");
     
    //Start
    echo("<hr> <font color = blue> sound.recognize_file_with_digits </font> <hr>");
     
    //1
    echo("1.Recognize the file with English numbers(0-9):");
    echo(sound.recognize_file_with_digits("test/mp3/4196092774.mp3") + " n");
     
    //2
    echo("2.Recognize the file with English numbers(0-9):");
    echo(sound.recognize_file_with_digits("test/mp3/80692.mp3") + " n");
     
    //3
    echo("<center> <h5> Download the file from Recaptcha V2 </h5> </center>");
    echo("3.Let's go to the polygon:");
    echo(browser.navigate("https://www.google.com/recaptcha/api2/demo") + "<br>");
     
    //4
    echo("4.Click I'm not a robot:");
    while(!div.get_by_attribute("class", "recaptcha-checkbox-checkmark", false, "0").is_visibled()) sleep(1);
    echo(div.get_by_attribute("class", "recaptcha-checkbox-checkmark", false, "0").send_mouse_click(4,4) + " n");
     
    //five
    echo("5.Press the audio version of the captcha:");
    while(!btn.get_by_name("recaptcha-audio-button", "1").is_visibled())
    {
        div.get_by_attribute("class", "recaptcha-checkbox-checkmark", false, "0").send_mouse_click(4,4);
        app.sleep(1);
    }
    echo(btn.get_by_name("recaptcha-audio-button", "1").send_mouse_click(5,5) + " n");
    sleep(4);
     
    //6
    echo("6.Click download:");
    window.execute_download_file();
    browser.set_default_download("download");
    browser.enable_download_file_dialog(true);
    file_os.delete("download/audio.mp3");
    while(!anchor.get_by_href("api2/payload/audio.mp3", false, "1").is_visibled())
    {
        btn.get_by_name("recaptcha-audio-button", "1").send_mouse_click(5,5);
        sleep(1);
    }
    echo(anchor.get_by_href("api2/payload/audio.mp3", false, "1").send_mouse_click(5,5) + " n");
    app.sleep(3);
    //waiting for download
    while(!file_os.is_exist("download/audio.mp3"))
      app.sleep(1);
     
     
    //7
    echo("7.Recognize the file with English numbers(0-9):");
    var digits = sound.recognize_file_with_digits("download/audio.mp3");
    echo(digits);
    sleep(1);
    if(digits == "false")
    {
        echo("There is no audio file in the correct format.(Perhaps we are requesting an audio file too often.Please try again later.)");
        app.quit();
    }
     
    //8
    echo(" n8.Enter the result:");
    browser.set_active_browser(0);
    echo(input.get_by_name("audio-response", "1").send_input(digits) + " n");
    btn.get_by_id("recaptcha-verify-button", false, "1").send_mouse_click();
    //end
    echo("<hr> <br>");
     
    //Quit
    app.quit();
  • en/objects/sound/sound_file/recognize_file_with_digits.txt · Last modified: 2026/08/05 22:47 (external edit)