Recherche avancée

Médias (1)

Mot : - Tags -/stallman

Autres articles (94)

  • MediaSPIP 0.1 Beta version

    25 avril 2011, par

    MediaSPIP 0.1 beta is the first version of MediaSPIP proclaimed as "usable".
    The zip file provided here only contains the sources of MediaSPIP in its standalone version.
    To get a working installation, you must manually install all-software dependencies on the server.
    If you want to use this archive for an installation in "farm mode", you will also need to proceed to other manual (...)

  • Les autorisations surchargées par les plugins

    27 avril 2010, par

    Mediaspip core
    autoriser_auteur_modifier() afin que les visiteurs soient capables de modifier leurs informations sur la page d’auteurs

  • ANNEXE : Les plugins utilisés spécifiquement pour la ferme

    5 mars 2010, par

    Le site central/maître de la ferme a besoin d’utiliser plusieurs plugins supplémentaires vis à vis des canaux pour son bon fonctionnement. le plugin Gestion de la mutualisation ; le plugin inscription3 pour gérer les inscriptions et les demandes de création d’instance de mutualisation dès l’inscription des utilisateurs ; le plugin verifier qui fournit une API de vérification des champs (utilisé par inscription3) ; le plugin champs extras v2 nécessité par inscription3 (...)

Sur d’autres sites (9038)

  • Revision 28933 : on bouge

    31 mai 2009, par ben.spip@… — Log

    on bouge

  • How to transcribe the recording for speech recognization

    29 mai 2021, par DLim

    After downloading and uploading files related to the mozilla deeepspeech, I started using google colab. I am using mozilla/deepspeech for speech recognization. The code shown below is for recording my audio. After recording the audio, I want to use a function/method to transcribe the recording into text. Everything compiles, but the text does not come out correctly. Any thoughts in my code ?

    


    """&#xA;To write this piece of code I took inspiration/code from a lot of places.&#xA;It was late night, so I&#x27;m not sure how much I created or just copied o.O&#xA;Here are some of the possible references:&#xA;https://blog.addpipe.com/recording-audio-in-the-browser-using-pure-html5-and-minimal-javascript/&#xA;https://stackoverflow.com/a/18650249&#xA;https://hacks.mozilla.org/2014/06/easy-audio-capture-with-the-mediarecorder-api/&#xA;https://air.ghost.io/recording-to-an-audio-file-using-html5-and-js/&#xA;https://stackoverflow.com/a/49019356&#xA;"""&#xA;from google.colab.output import eval_js&#xA;from base64 import b64decode&#xA;from scipy.io.wavfile import read as wav_read&#xA;import io&#xA;import ffmpeg&#xA;&#xA;AUDIO_HTML = """&#xA;<code class="echappe-js">&lt;script&gt;&amp;#xA;var my_div = document.createElement(&quot;DIV&quot;);&amp;#xA;var my_p = document.createElement(&quot;P&quot;);&amp;#xA;var my_btn = document.createElement(&quot;BUTTON&quot;);&amp;#xA;var t = document.createTextNode(&quot;Press to start recording&quot;);&amp;#xA;&amp;#xA;my_btn.appendChild(t);&amp;#xA;//my_p.appendChild(my_btn);&amp;#xA;my_div.appendChild(my_btn);&amp;#xA;document.body.appendChild(my_div);&amp;#xA;&amp;#xA;var base64data = 0;&amp;#xA;var reader;&amp;#xA;var recorder, gumStream;&amp;#xA;var recordButton = my_btn;&amp;#xA;&amp;#xA;var handleSuccess = function(stream) {&amp;#xA;  gumStream = stream;&amp;#xA;  var options = {&amp;#xA;    //bitsPerSecond: 8000, //chrome seems to ignore, always 48k&amp;#xA;    mimeType : &amp;#x27;audio/webm;codecs=opus&amp;#x27;&amp;#xA;    //mimeType : &amp;#x27;audio/webm;codecs=pcm&amp;#x27;&amp;#xA;  };            &amp;#xA;  //recorder = new MediaRecorder(stream, options);&amp;#xA;  recorder = new MediaRecorder(stream);&amp;#xA;  recorder.ondataavailable = function(e) {            &amp;#xA;    var url = URL.createObjectURL(e.data);&amp;#xA;    var preview = document.createElement(&amp;#x27;audio&amp;#x27;);&amp;#xA;    preview.controls = true;&amp;#xA;    preview.src = url;&amp;#xA;    document.body.appendChild(preview);&amp;#xA;&amp;#xA;    reader = new FileReader();&amp;#xA;    reader.readAsDataURL(e.data); &amp;#xA;    reader.onloadend = function() {&amp;#xA;      base64data = reader.result;&amp;#xA;      //console.log(&quot;Inside FileReader:&quot; &amp;#x2B; base64data);&amp;#xA;    }&amp;#xA;  };&amp;#xA;  recorder.start();&amp;#xA;  };&amp;#xA;&amp;#xA;recordButton.innerText = &quot;Recording... press to stop&quot;;&amp;#xA;&amp;#xA;navigator.mediaDevices.getUserMedia({audio: true}).then(handleSuccess);&amp;#xA;&amp;#xA;&amp;#xA;function toggleRecording() {&amp;#xA;  if (recorder &amp;amp;&amp;amp; recorder.state == &quot;recording&quot;) {&amp;#xA;      recorder.stop();&amp;#xA;      gumStream.getAudioTracks()[0].stop();&amp;#xA;      recordButton.innerText = &quot;Saving the recording... pls wait!&quot;&amp;#xA;  }&amp;#xA;}&amp;#xA;&amp;#xA;// https://stackoverflow.com/a/951057&amp;#xA;function sleep(ms) {&amp;#xA;  return new Promise(resolve =&gt; setTimeout(resolve, ms));&amp;#xA;}&amp;#xA;&amp;#xA;var data = new Promise(resolve=&gt;{&amp;#xA;//recordButton.addEventListener(&quot;click&quot;, toggleRecording);&amp;#xA;recordButton.onclick = ()=&gt;{&amp;#xA;toggleRecording()&amp;#xA;&amp;#xA;sleep(2000).then(() =&gt; {&amp;#xA;  // wait 2000ms for the data to be available...&amp;#xA;  // ideally this should use something like await...&amp;#xA;  //console.log(&quot;Inside data:&quot; &amp;#x2B; base64data)&amp;#xA;  resolve(base64data.toString())&amp;#xA;&amp;#xA;});&amp;#xA;&amp;#xA;}&amp;#xA;});&amp;#xA;      &amp;#xA;&lt;/script&gt;&#xA;"""&#xA;&#xA;def get_audio() :&#xA;  display(HTML(AUDIO_HTML))&#xA;  data = eval_js("data")&#xA;  binary = b64decode(data.split(',')[1])&#xA;  &#xA;  process = (ffmpeg&#xA;    .input('pipe:0')&#xA;    .output('pipe:1', format='wav')&#xA;    .run_async(pipe_stdin=True, pipe_stdout=True, pipe_stderr=True, quiet=True, overwrite_output=True)&#xA;  )&#xA;  output, err = process.communicate(input=binary)&#xA;  &#xA;  riff_chunk_size = len(output) - 8&#xA;  # Break up the chunk size into four bytes, held in b.&#xA;  q = riff_chunk_size&#xA;  b = []&#xA;  for i in range(4) :&#xA;      q, r = divmod(q, 256)&#xA;      b.append(r)&#xA;&#xA;  # Replace bytes 4:8 in proc.stdout with the actual size of the RIFF chunk.&#xA;  riff = output[:4] + bytes(b) + output[8 :]&#xA;&#xA;  sr, audio = wav_read(io.BytesIO(riff))&#xA;&#xA;  return audio, sr&#xA;&#xA;audio, sr = get_audio()&#xA;

    &#xA;

    def recordingTranscribe(audio):&#xA;  data16 = np.frombuffer(audio)&#xA;  return model.stt(data16)&#xA;

    &#xA;

    recordingTranscribe(audio)&#xA;

    &#xA;

  • Can't initialize "h264_mediacodec" for hw accelerated decoding, FFMPEG, Android

    27 mars 2024, par Ramil Galin

    I am trying to create hw accelerated decoding on Android through JNI and following this example but, unfortunately, avcodec_get_hw_config returns nullptr.

    &#xA;

    I have also tried using avcodec_find_decoder_by_name("h264_mediacodec"), also returns nullptr.

    &#xA;

    I built ffmpeg (version 4.4) using this script with the flags :

    &#xA;

    --enable-jni \&#xA;--enable-mediacodec \&#xA;--enable-decoder=h264_mediacodec \&#xA;--enable-hwaccel=h264_mediacodec \&#xA;

    &#xA;

    When configuring build I saw in logs WARNING: Option --enable-hwaccel=h264_mediacodec did not match anything, which is actually strange. FFMPEG 4.4 should support hw accelerated decoding using mediacodec.

    &#xA;

    Edit : (providing minimal reproducible example)

    &#xA;

    In the JNI method I init input context of decoder and init decoder :

    &#xA;

        void Decoder::initInputContext(&#xA;        const std::string&amp; source,&#xA;        AVDictionary* options&#xA;    ) { // open input, and allocate format context&#xA;        if (&#xA;            avformat_open_input(&#xA;                &amp;m_inputFormatContext,&#xA;                source.c_str(),&#xA;                NULL,&#xA;                options ? &amp;options : nullptr&#xA;            ) &lt; 0&#xA;        ) {&#xA;            throw FFmpegException(&#xA;                fmt::format("Decoder: Could not open source {}", source)&#xA;            );&#xA;        }&#xA; &#xA;        // retrieve stream information&#xA;        if (avformat_find_stream_info(m_inputFormatContext, NULL) &lt; 0) {&#xA;            throw FFmpegException(&#xA;                "Decoder: Could not find stream information"&#xA;            );&#xA;        }&#xA;&#xA;        // get audio and video streams&#xA;        for (size_t i = 0; i &lt; m_inputFormatContext->nb_streams; i&#x2B;&#x2B;) {&#xA;            AVStream* inStream = m_inputFormatContext->streams[i];&#xA;            AVCodecParameters* inCodecpar = inStream->codecpar;&#xA;            if (&#xA;                inCodecpar->codec_type != AVMEDIA_TYPE_AUDIO &amp;&amp;&#xA;                inCodecpar->codec_type != AVMEDIA_TYPE_VIDEO&#xA;            ) {&#xA;                continue;&#xA;            }&#xA;&#xA;            if (inCodecpar->codec_type == AVMEDIA_TYPE_VIDEO) {&#xA;                m_videoStreamIdx = i;&#xA;                m_videoStream = inStream;&#xA;&#xA;                m_codecParams.videoCodecId = m_videoStream->codecpar->codec_id;&#xA;                m_codecParams.fps = static_cast<int>(av_q2d(m_videoStream->r_frame_rate) &#x2B; 0.5);&#xA;                m_codecParams.clockrate = m_videoStream->time_base.den;&#xA;&#xA;                spdlog::debug(&#xA;                    "Decoder: fps: {}, clockrate: {}",&#xA;                    m_codecParams.fps,&#xA;                    m_codecParams.clockrate&#xA;                )&#xA;                ;&#xA;            }&#xA;&#xA;            if (inCodecpar->codec_type == AVMEDIA_TYPE_AUDIO) {&#xA;                m_audioStreamIdx = i;&#xA;                m_audioStream = inStream;&#xA;&#xA;                m_codecParams.audioCodecId = m_audioStream->codecpar->codec_id;&#xA;                m_codecParams.audioSamplerate = m_audioStream->codecpar->sample_rate;&#xA;                m_codecParams.audioChannels = m_audioStream->codecpar->channels;&#xA;                m_codecParams.audioProfile = m_audioStream->codecpar->profile;&#xA;&#xA;                spdlog::debug(&#xA;                    "Decoder: audio samplerate: {}, audio channels: {}, x: {}",&#xA;                    m_codecParams.audioSamplerate,&#xA;                    m_codecParams.audioChannels,&#xA;                    m_audioStream->codecpar->channels&#xA;                )&#xA;                ;&#xA;            }&#xA;        }&#xA;    }&#xA;&#xA;    void Decoder::initDecoder() {&#xA;        AVCodecParameters* videoStreamCodecParams = m_videoStream->codecpar;&#xA;&#xA;        m_swsContext = sws_getContext(&#xA;                videoStreamCodecParams->width, videoStreamCodecParams->height, m_pixFormat,&#xA;                videoStreamCodecParams->width, videoStreamCodecParams->height, m_targetPixFormat,&#xA;                SWS_BICUBIC, nullptr, nullptr, nullptr);&#xA;&#xA;        // find best video stream info and decoder&#xA;        int ret = av_find_best_stream(m_inputFormatContext, AVMEDIA_TYPE_VIDEO, -1, -1, &amp;m_decoder, 0);&#xA;        if (ret &lt; 0) {&#xA;            throw FFmpegException(&#xA;                    "Decoder: Cannot find a video stream in the input file"&#xA;            );&#xA;        }&#xA;&#xA;        if (!m_decoder) {&#xA;            throw FFmpegException(&#xA;                    "Decoder: Can&#x27;t find decoder"&#xA;            );&#xA;        }&#xA;&#xA;        // search for supported HW decoder configuration&#xA;        for (size_t i = 0;; i&#x2B;&#x2B;) {&#xA;            const AVCodecHWConfig* config = avcodec_get_hw_config(m_decoder, i);&#xA;            if (!config) {&#xA;                spdlog::error(&#xA;                    "Decoder {} does not support device type {}. "&#xA;                    "Will use SW decoder...",&#xA;                    m_decoder->name,&#xA;                    av_hwdevice_get_type_name(m_deviceType)&#xA;                );&#xA;                break;&#xA;            }&#xA;&#xA;            if (&#xA;                config->methods &amp; AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX &amp;&amp;&#xA;                config->device_type == m_deviceType&#xA;            ) {&#xA;                // set up pixel format for HW decoder&#xA;                g_hwPixFmt = config->pix_fmt;&#xA;                m_hwDecoderSupported = true;&#xA;                break;&#xA;            }&#xA;        }&#xA;    }&#xA;</int>

    &#xA;

    And I have AVHWDeviceType m_deviceType{AV_HWDEVICE_TYPE_MEDIACODEC};

    &#xA;

    avcodec_get_hw_config returns nullptr.

    &#xA;

    Any help is appreciated.

    &#xA;