pedrojlazevedo / python-video-generator

This repository creates videos automatically by giving one single input.
MIT License
3 stars 0 forks source link

PermissionError: [WinError 32] The process cannot access the file because it is being used by another process #6

Open Thrqureshi opened 2 years ago

Thrqureshi commented 2 years ago

Hi there

I am not an expert in Python but this code is always giving me this error

(PermissionError: [WinError 32] The process cannot access the file because it is being used by another process)

There is only one application running which is anaconda with Admin privileges

Any help will be greatly appreciated

Thanks

Traceback (most recent call last): File "C:\Users\User\Desktop\Python\python-video-generator\orchestrator.py", line 73, in generate_video self.image_parser.retrieve_best_image(sentence) File "C:\Users\User\Desktop\Python\python-video-generator\python_video_generator\image_parser\bing_image_retrieval.py", line 73, in retrieve_best_image self.download_images(sentence) File "C:\Users\User\Desktop\Python\python-video-generator\python_video_generator\image_parser\bing_image_retrieval.py", line 42, in download_images bing.download_images( File "C:\Users\User\Desktop\Python\python-video-generator\python_video_generator\video_editor\bing.py", line 65, in download_images rename_images(image_dir, query) File "C:\Users\User\Desktop\Python\python-video-generator\python_video_generator\video_editor\bing.py", line 85, in rename_images os.rename(src, dst) PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'images\funny video vlog blog\#tmp#_7.jpg' -> 'images\funny video vlog blog\funny video vlog blog_8.jpg'

pedrojlazevedo commented 2 years ago

Hello.

Thank you for trying this code out. Can you try to increase the sleep timing here https://github.com/pedrojlazevedo/python-video-generator/blob/main/python_video_generator/video_editor/bing.py#L64?

Let me know if it works!

Thrqureshi commented 2 years ago

Thanks for the quick response

it works by increasing the sleep time

I have 2 more issue

  1. there is no file name called stars.png (which I will create a file under root directory)
  2. Do we have to install espeak separately. (I am using window 11)

raise Exception(" [!] No espeak backend found. Install espeak-ng or espeak to your system.") Exception: [!] No espeak backend found. Install espeak-ng or espeak to your system.

Traceback (most recent call last): File "C:\ProgramData\Anaconda3\envs\video_generator\lib\runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\ProgramData\Anaconda3\envs\video_generator\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "C:\ProgramData\Anaconda3\envs\video_generator\Scripts\tts.exe__main.py", line 7, in File "C:\ProgramData\Anaconda3\envs\video_generator\lib\site-packages\TTS\bin\synthesize.py", line 316, in main synthesizer = Synthesizer( File "C:\ProgramData\Anaconda3\envs\video_generator\lib\site-packages\TTS\utils\synthesizer.py", line 76, in init self._load_tts(tts_checkpoint, tts_config_path, use_cuda) File "C:\ProgramData\Anaconda3\envs\video_generator\lib\site-packages\TTS\utils\synthesizer.py", line 113, in _load_tts self.tts_model = setup_tts_model(config=self.tts_config) File "C:\ProgramData\Anaconda3\envs\video_generator\lib\site-packages\TTS\tts\models__init__.py", line 13, in setup_model model = MyModel.init_from_config(config, samples) File "C:\ProgramData\Anaconda3\envs\video_generator\lib\site-packages\TTS\tts\models\vits.py", line 1742, in init_from_config tokenizer, new_config = TTSTokenizer.init_from_config(config) File "C:\ProgramData\Anaconda3\envs\video_generator\lib\site-packages\TTS\tts\utils\text\tokenizer.py", line 188, in init_from_config phonemizer = get_phonemizer_by_name(config.phonemizer, phonemizer_kwargs) File "C:\ProgramData\Anaconda3\envs\video_generator\lib\site-packages\TTS\tts\utils\text\phonemizers__init__.py", line 44, in get_phonemizer_by_name return ESpeak(kwargs) File "C:\ProgramData\Anaconda3\envs\video_generator\lib\site-packages\TTS\tts\utils\text\phonemizers\espeak_wrapper.py", line 91, in init raise Exception(" [!] No espeak backend found. Install espeak-ng or espeak to your system.") Exception: [!] No espeak backend found. Install espeak-ng or espeak to your system. Traceback (most recent call last): File "C:\Users\User\Desktop\Python\python-video-generator\orchestrator.py", line 81, in generate_video compose_video(document) File "C:\Users\User\Desktop\Python\python-video-generator\python_video_generator\video_editor\generate_video.py", line 117, in compose_video images = [make_star_wars_video(title=document.query)] File "C:\Users\User\Desktop\Python\python-video-generator\python_video_generator\video_editor\star_wars_opening.py", line 78, in make_star_wars_video stars = ImageClip('stars.png') File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\moviepy\video\VideoClip.py", line 889, in init img = imread(img) File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\imageio__init__.py", line 97, in imread return imread_v2(uri, format=format, kwargs) File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\imageio\v2.py", line 226, in imread with imopen(uri, "ri", imopen_args) as file: File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\imageio\core\imopen.py", line 113, in imopen request = Request(uri, io_mode, format_hint=format_hint, extension=extension) File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\imageio\core\request.py", line 248, in init__ self._parse_uri(uri) File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\imageio\core\request.py", line 408, in _parse_uri raise FileNotFoundError("No such file: '%s'" % fn) FileNotFoundError: No such file: 'C:\Users\User\Desktop\Python\python-video-generator\stars.png'

pedrojlazevedo commented 2 years ago

Hey!

This is excellent to understand the code reproducibility. I did install a lot of packages and, with everything going on, I didn't take notes about all the requirements.

I already updated the main branch with both the missing file and the increasing sleeping time.

Now, regarding the espeak-ng on windows: please follow these steps to install https://github.com/espeak-ng/espeak-ng/blob/master/docs/guide.md#windows. Once again, let me know if it works to update the README.MD :)

Thrqureshi commented 2 years ago

Thanks for replying again

yes, I have downloaded and the error has gone now

do you know anything about IndexError: list index out of range

Traceback (most recent call last): File "C:\Users\User\Desktop\Python\python-video-generator\orchestrator.py", line 73, in generate_video self.image_parser.retrieve_best_image(sentence) File "C:\Users\User\Desktop\Python\python-video-generator\python_video_generator\image_parser\bing_image_retrieval.py", line 74, in retrieve_best_image self.select_best_image(sentence) File "C:\Users\User\Desktop\Python\python-video-generator\python_video_generator\image_parser\bing_image_retrieval.py", line 138, in select_best_image sentence.best_image = sentence.images[self.image_selected - 1] IndexError: list index out of range

pedrojlazevedo commented 2 years ago

Hello!

Thank you for the update. Can you please provide the steps (the selected document) to reproduce the error at my end?

Thank you