Spaces:
Runtime error
Runtime error
File size: 1,978 Bytes
b666de2 05907ba b666de2 05907ba 8c45656 05907ba d2ea659 05907ba 014ee66 8c45656 05907ba cc5f18e ba27b4a 8c45656 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | import gradio as gr
import os
isFileType = False # To return true if the file type is 'mp4'
isFileSize = False # To return true if the file > 16mb
# Validate the video file
def predict_video(input_video):
filename = input_video.name # Get the uploaded filename
file_size = os.path.getsize(input_video) # Get the file size in bytes
# Check if it's not an MP4 file
if not filename.lower().endswith('.mp4'):
isFileType = True
return "Error: Please upload an MP4 video file."
# Checks if the file is above 16mb
if file_size > 16 *1024 * 1024: # 1mb = 1024bytes
isFileSize = True
return "Error: The upload exceeds file size 16MB. Please upload a smaller file."
# Your processing code here (if the file type is correct)
return "Video processed successfully!"
inputs = gr.File(label="Upload a video")
output = gr.Textbox()
with gr.Blocks() as demo:
gr.Markdown(
"""
# Phone brr
Welcome to the Hugging face Space of Phone brr we aim to create more immersive content for mobile phones with the use of haptic audio, this demo focuses on working for a very commonly used special effect of explosions hope you enjoy it.
Instructions
Step 1: Upload the example video to get the relevant timeframes that require haptics <a href="https://portal.vision.cognitive.azure.com/demo/video-summary-and-frame-locator">Azure Cognitive Services Video Summary and Frame Locator</a> with explosions as the query.
Step 2: Download the generated audio from <a href="https://phonebrrdemonstration2.blob.core.windows.net/audio3second0001/3_second_explosion_00001.flac">this ai-generated haptic audio</a>.
Step 3: Mix the Audio using any app of your choice and master the audio with <a href="https://aimastering.com/">ai-mastering program</a>
"""),
gr.Interface(fn=predict_video, inputs=inputs, outputs=output).launch()
if __name__ == "__main__":
demo.launch(share=True)
|