Spaces:
Runtime error
Runtime error
| import tempfile | |
| import os | |
| try: | |
| from modelscope.pipelines import pipeline | |
| from modelscope.outputs import OutputKeys | |
| MODELSCOPE_AVAILABLE = True | |
| except ImportError: | |
| MODELSCOPE_AVAILABLE = False | |
| def generate_video(prompt): | |
| if not MODELSCOPE_AVAILABLE: | |
| raise ImportError("The modelscope library is not installed or there was an error importing it. " | |
| "Please make sure all dependencies are correctly installed.") | |
| pipe = pipeline('text-to-video-synthesis', 'damo/text-to-video-synthesis') | |
| output = pipe({'text': prompt}) | |
| video = output[OutputKeys.OUTPUT_VIDEO] | |
| with tempfile.NamedTemporaryFile(delete=False, suffix='.mp4') as temp_file: | |
| temp_path = temp_file.name | |
| with open(temp_path, 'wb') as f: | |
| f.write(video) | |
| return temp_path |