- Hi everyone!, we set up the demo on Gradio but ran into the following
problem
def extract_audio(input_video):#input_video=‘video_path+name.mp4’
# Load the input video
video = mp.VideoFileClip(input_video)
# Extract audio from the video
audio = video.audio
extracted_audio = audio.write_audiofile("audio.wav")
return extracted_audio
import gradio as gr
gradio_interface = gr.Interface(
fn=lambda video_file: extract_audio(video_file),
inputs=gr.inputs.File(label=“Video File”),
outputs=gr.outputs.Audio(type=“filepath”),
title=“Extract_audio”,
description=“Extract audio from a video file”,
)
Launch
gradio_interface.launch(share=True, debug=True)
error
File "/usr/local/lib/python3.9/dist-packages/gradio/routes.py", line 393, in run_predict
output = await app.get_blocks().process_api(
File "/usr/local/lib/python3.9/dist-packages/gradio/blocks.py", line 1108, in process_api
result = await self.call_function(
File "/usr/local/lib/python3.9/dist-packages/gradio/blocks.py", line 915, in call_function
prediction = await anyio.to_thread.run_sync(
File "/usr/local/lib/python3.9/dist-packages/anyio/to_thread.py", line 31, in run_sync
return await get_asynclib().run_sync_in_worker_thread(
File "/usr/local/lib/python3.9/dist-packages/anyio/_backends/_asyncio.py", line 937, in run_sync_in_worker_thread
return await future
File "/usr/local/lib/python3.9/dist-packages/anyio/_backends/_asyncio.py", line 867, in run
result = context.run(func, *args)
File "<ipython-input-4-0ccd69470b96>", line 6, in <lambda>
fn=lambda video_file: extract_audio(video_file),
File "<ipython-input-2-db86fbda33af>", line 15, in extract_audio
video = mp.VideoFileClip(input_video)
File "/usr/local/lib/python3.9/dist-packages/moviepy/video/io/VideoFileClip.py", line 88, in __init__
self.reader = FFMPEG_VideoReader(filename, pix_fmt=pix_fmt,
File "/usr/local/lib/python3.9/dist-packages/moviepy/video/io/ffmpeg_reader.py", line 35, in __init__
infos = ffmpeg_parse_infos(filename, print_infos, check_duration,
File "/usr/local/lib/python3.9/dist-packages/moviepy/video/io/ffmpeg_reader.py", line 244, in ffmpeg_parse_infos
is_GIF = filename.endswith('.gif')
File "/usr/lib/python3.9/tempfile.py", line 612, in __getattr__
a = getattr(file, name)
AttributeError: '_io.BufferedRandom' object has no attribute 'endswith'
. Anyone who could give me some advice on how to make it work?