clipsai icon indicating copy to clipboard operation
clipsai copied to clipboard

get MIME error

Open catii-am opened this issue 11 months ago • 0 comments

I get an error in the get_mime_primary_type function that there is supposedly no file, in fact it is, before running the script I made an additional check for the presence of the file. In the function itself I added logs that indicate the absence of the file.

My code:

from clipsai import ClipFinder, Transcriber
import os

audio_file_path = r"D:\project\vedro.mp4"
if not os.path.exists(audio_file_path):
    print(f"File not found: {audio_file_path}")
else:
    print(f"File found: {audio_file_path}")
    transcriber = Transcriber()
    transcription = transcriber.transcribe(audio_file_path)

    clipfinder = ClipFinder()
    clips = clipfinder.find_clips(transcription=transcription)

    print("StartTime: ", clips[0].start_time)
    print("EndTime: ", clips[0].end_time)

What I changed:

    def get_mime_primary_type(self) -> str:
        """
        Gets the file type from the mime type.

        Parameters
        ----------
        None

        Returns
        -------
        str
            The file type retrieved from the mime type.
        """
        print(f"Trying to get MIME type for: {self.path}")  # Added
        mime_type = self.get_mime_type()  # Added
        print("MIME type:", mime_type)  # Added

        file_type, _ = self.get_mime_type().split("/")
        return file_type

Error:

D:\project\.venv\Scripts\python.exe "D:\project\shorts ai.py" 
[nltk_data] Downloading package punkt to
[nltk_data]     C:\Users\catik\AppData\Roaming\nltk_data...
[nltk_data]   Package punkt is already up-to-date!
INFO:speechbrain.utils.quirks:Applied quirks (see `speechbrain.utils.quirks`): [allow_tf32, disable_jit_profiling]
INFO:speechbrain.utils.quirks:Excluded quirks specified by the `SB_DISABLE_QUIRKS` environment (comma-separated list): []
File found: D:\project\vedro.mp4
No language specified, language will be first be detected for each audio file (increases inference time).
>>Performing voice activity detection using Pyannote...
Lightning automatically upgraded your loaded checkpoint from v1.5.4 to v2.5.0.post0. To apply the upgrade to your files permanently, run `python -m pytorch_lightning.utilities.upgrade_checkpoint D:\project\.venv\Lib\site-packages\whisperx\assets\pytorch_model.bin`
Model was trained with pyannote.audio 0.0.1, yours is 3.3.2. Bad things might happen unless you revert pyannote.audio to 0.x.
Model was trained with torch 1.10.0+cu102, yours is 2.2.2+cpu. Bad things might happen unless you revert torch to 1.x.
Trying to get MIME type for: D:\project\vedro.mp4
MIME type: cannot open `D:\project\vedro.mp4' (No such file or directory)
Traceback (most recent call last):
  File "D:\project\shorts ai.py", line 12, in <module>
    transcription = transcriber.transcribe(audio_file_path)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\project\.venv\Lib\site-packages\clipsai\transcribe\transcriber.py", line 99, in transcribe
    media_file = editor.instantiate_as_temporal_media_file(audio_file_path)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\project\.venv\Lib\site-packages\clipsai\media\editor.py", line 1252, in instantiate_as_temporal_media_file
    media_file.assert_exists()
  File "D:\project\.venv\Lib\site-packages\clipsai\filesys\object.py", line 157, in assert_exists
    msg = self.check_exists()
          ^^^^^^^^^^^^^^^^^^^
  File "D:\project\.venv\Lib\site-packages\clipsai\media\temporal_media_file.py", line 65, in check_exists
    msg = super().check_exists()
          ^^^^^^^^^^^^^^^^^^^^^^
  File "D:\project\.venv\Lib\site-packages\clipsai\media\media_file.py", line 79, in check_exists
    if file.get_mime_primary_type() not in valid_media_file_types:
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\project\.venv\Lib\site-packages\clipsai\filesys\file.py", line 236, in get_mime_primary_type
    file_type, _ = self.get_mime_type().split("/")
    ^^^^^^^^^^^^
ValueError: not enough values to unpack (expected 2, got 1)

Process finished with exit code 1

Used on Windows 11, IDE PyCharm

catii-am avatar Feb 28 '25 18:02 catii-am