Recherche avancée

Médias (39)

Mot : - Tags -/audio

Autres articles (91)

  • Emballe médias : à quoi cela sert ?

    4 février 2011, par

    Ce plugin vise à gérer des sites de mise en ligne de documents de tous types.
    Il crée des "médias", à savoir : un "média" est un article au sens SPIP créé automatiquement lors du téléversement d’un document qu’il soit audio, vidéo, image ou textuel ; un seul document ne peut être lié à un article dit "média" ;

  • Submit bugs and patches

    13 avril 2011

    Unfortunately a software is never perfect.
    If you think you have found a bug, report it using our ticket system. Please to help us to fix it by providing the following information : the browser you are using, including the exact version as precise an explanation as possible of the problem if possible, the steps taken resulting in the problem a link to the site / page in question
    If you think you have solved the bug, fill in a ticket and attach to it a corrective patch.
    You may also (...)

  • De l’upload à la vidéo finale [version standalone]

    31 janvier 2010, par

    Le chemin d’un document audio ou vidéo dans SPIPMotion est divisé en trois étapes distinctes.
    Upload et récupération d’informations de la vidéo source
    Dans un premier temps, il est nécessaire de créer un article SPIP et de lui joindre le document vidéo "source".
    Au moment où ce document est joint à l’article, deux actions supplémentaires au comportement normal sont exécutées : La récupération des informations techniques des flux audio et video du fichier ; La génération d’une vignette : extraction d’une (...)

Sur d’autres sites (3255)

  • Why do I get UnknownValueError when trying to run .recognize_google ?

    21 juillet 2022, par John Smith

    Following code is meant to transcribe a long audio file to text. It is to do this piece by piece. trimmed.wav holds a 15-second-long piece of a longer audio file (whose path is stored in fname) :

    


    #!/usr/bin/env python3

from subprocess import run
from sys import exit

italic = '\33[3m'
end = '\33[m'

try:
    from speech_recognition import AudioFile, Recognizer
except:
    run("pip3 install SpeechRecognition", shell=True)
    from speech_recognition import AudioFile, Recognizer

def transcribe_piece(fname, lang, stime):
    extension = fname[-3:]
    etime = stime + 15
    cmd = f"ffmpeg -ss {stime} -to {etime} -i {fname} -c copy trimmed.{extension} >/dev/null 2>&1"
    run(cmd, shell=True)
    cmd = f"ffmpeg -i trimmed.{extension} -f wav trimmed.wav >/dev/null 2>&1"
    run(cmd, shell=True)
    r = Recognizer()    
    af = AudioFile("trimmed.wav")
    with af as source:
        r.adjust_for_ambient_noise(source)
        audio = r.record(source)
        t = r.recognize_google(audio, language=lang)#UnknownValueError() speech_recognition.UnknownValueError
        print(f"{italic}{t}{end}")
        with open("of", "w") as f:
            f.write(f"{t}\n")
    run(f"rm trimmed.{extension}", shell=True) 
    run(f"rm trimmed.wav", shell=True)
    
    

fname = input("File name? Skip the path if the file is in CWD. The usage of ~ is allowed.\n")

lang = input("""Specify one of the following languages:
fr-BE, fr-CA, fr-FR, fr-CH

en-AU, en-CA, en-GH, en-HK, en-IN, en-IE, en-KE, en-NZ, en-PK, en-PH, en-SG, en-ZA, en-TZ, en-GB, en-US

es-AR, es-BO, es-BO, es-CL, es-CO, es-CR, es-DO, es-EC, es-SV, es-SV, es-GT, es-HN, es-MX, es-NI, es-PA, es-PY, es-PE, es-PR, es-ES, es-US, es-UY, es-VE\n""")


#for stime in range(0, 10000, 15):
#    try:
#        transcribe_piece(fname, lang, stime)
#    except:
#        run("shred -u trimmed.wav" , shell=True) 
        #run("shred -u trimmed.wav >/dev/null 2>&1" , shell=True) 
#        exit(0)
        
for stime in range(0, 10000, 15):#this loop is only for the sake of debugging, use try/except above
    transcribe_piece(fname, lang, stime)



    


    It gives me the following error :

    


    Traceback (most recent call last):&#xA;  File "/home/jim/CS/SoftwareDevelopment/MySoftware/Python/speech-to-text/long-audio-to-text.py", line 61, in <module>&#xA;    transcribe_piece(fname, lang, stime)&#xA;  File "/home/jim/CS/SoftwareDevelopment/MySoftware/Python/speech-to-text/long-audio-to-text.py", line 31, in transcribe_piece&#xA;    t = r.recognize_google(audio, language=lang)&#xA;  File "/home/jim/.local/lib/python3.10/site-packages/speech_recognition/__init__.py", line 858, in recognize_google&#xA;    if not isinstance(actual_result, dict) or len(actual_result.get("alternative", [])) == 0: raise UnknownValueError()&#xA;speech_recognition.UnknownValueError&#xA;&#xA;</module>

    &#xA;

    The said error refers to line 31, that is t = r.recognize_google(audio, language=lang).&#xA;Why do I get this error ? How might I rewrite this code so that such error does not appear ?

    &#xA;

  • Python subprocess or os.system not working with ffmpeg

    13 février 2024, par confused

    I've been trying to get this darn programming run since last night and cannot seem to get anything to work. I want to first trim the video and then resize the video. I'm reading which video and what to give the final name from a text file, over 780 lines long, quite a few videos.

    &#xA;

    Thus far with every idea under the sun I have tried, subprocess and os.system, I can't get anything more than error statements or right now all I get is no file creation of any kind. How the heck do I get this to work correctly ?

    &#xA;

    import ffmpeg&#xA;import subprocess&#xA;import os&#xA;&#xA;os.chdir(&#x27;/home/Downloads/SRs/&#x27;)&#xA;a = open(&#x27;SRt.txt&#x27;, &#x27;r&#x27;)&#xA;b = a.readlines()&#xA;a.close()&#xA;for c in range(0, len(b)-1):&#xA;    words = list(b[c].split(" "))&#xA;    d = len(words)&#xA;    e = words[d-1]&#xA;    f = b[c].replace(e, &#x27;FR&#x27; &#x2B; str(c) &#x2B; &#x27;.mp4&#x27;)&#xA;    words[d-1] = &#x27;FR&#x27; &#x2B; str(c) &#x2B; &#x27;.mp4&#x27;&#xA;    print(f)&#xA;    subprocess.call(f, shell=True)&#xA;    subprocess.call([&#xA;        &#x27;ffmpeg&#x27;,&#xA;        &#x27;-i&#x27;,&#xA;        "&#x27;FR&#x27; &#x2B; str(c) &#x2B; &#x27;.mp4&#x27;",&#xA;        &#x27;-vf scale=320:240&#x27;,&#xA;        words[d-1],&#xA;        ])&#xA;

    &#xA;

    Here are some examples of what the original file would look like :

    &#xA;

     ffmpeg -i SR.mp4 -ss 00:00:00 -to 00:01:22 -c:v copy -a copy CPH.mp4&#xA; ffmpeg -i SR.mp4 -ss 00:01:24 -to 00:02:58 -c:v copy -a copy CG.mp4&#xA; ffmpeg -i SR.mp4 -ss 00:02:59 -to 00:05:41 -c:v copy -a copy CSGP.mp4&#xA;

    &#xA;

    Nothing fancy just separating video in its own individual segments and then resaving it before resizing it.

    &#xA;

    I tried :

    &#xA;

    z=subprocess.call(f, shell=True, stdout=subprocess.PIPE)&#xA;print(z)&#xA;

    &#xA;

    But all I get is '1'.

    &#xA;

    When I changed it to :

    &#xA;

    z=subprocess.call(f, shell=True, stderr=subprocess.PIPE)&#xA;print(z)&#xA;

    &#xA;

    All I get is '1'.

    &#xA;

    Maybe I'm doing something wrong.

    &#xA;

  • Python - getting duration of a video with ffprobe and splitting the video into pieces

    22 octobre 2018, par ZelelB

    I am trying to split a video with ffmpeg, implementing a python script.

    I am getting this error :

    Command '['ffprobe', '-i', 'path_to_my_video/MVI_0731.MP4', '-hide_banner']' returned non-zero exit status 1.

    Here is the code I am using to split the video :

    for video_file in video_files:
           try:
               # Call "ffprobe" to get duration of input video.
               ffprobe_process = subprocess.run(args=["ffprobe", "-i", video_file, "-hide_banner"],
                                              check=True,
                                              stdout=subprocess.PIPE,
                                              stderr=subprocess.PIPE,
                                              encoding="utf-8",
                                              shell=True)

               # "ffprobe" writes to stderr instead of stdout!
               duration_string = extract_duration_from_ffprobe_output(ffprobe_process.stderr)            
               duration_in_seconds = duration_string_to_seconds(duration_string)

               # Make start_stop_list
               start_stop_list = read_start_stop_list(start_stop_lists[nbr_video])
               nbr_video += 1
               total_pieces = int(len(start_stop_list))

    This is the line causing the problem :

    ffprobe_process = subprocess.run(args=["ffprobe", "-i", video_file, "-hide_banner"],
                                              check=True,
                                              stdout=subprocess.PIPE,
                                              stderr=subprocess.PIPE,
                                              encoding="utf-8",
                                              shell=True)

    When I change it to this line of code :

    ffprobe_process = subprocess.run(args=['ffprobe', '-i', video_file, '-show_entries', 'format=duration', '-v', 'quiet', '-of', 'csv=%s' % ("p=0")])

    it works, I mean, the script goes after that line, but then throws the following error at the next line :

    470.240000
    expected string or bytes-like object

    470.240000 is the right duration of my video. So the new line that I changed it with works better, but still not working with my code somehow.

    Anyone has an idea how I can solve this ?