ArthurFDLR / whisper-youtube

🔉 Youtube Videos Transcription with OpenAI's Whisper
https://colab.research.google.com/github/ArthurFDLR/whisper-youtube/blob/main/whisper_youtube.ipynb
MIT License
352 stars 105 forks source link

fix a little bug in exportTranscriptFile #14

Closed lizhuoq closed 8 months ago

ArthurFDLR commented 8 months ago

I get the following error with your modification:

AttributeError                            Traceback (most recent call last)
[<ipython-input-8-555bcf62c33a>](https://localhost:8080/#) in <cell line: 102>()
    135     if output_format=="all":
    136         for ext in ('.txt', '.vtt', '.srt', '.tsv', '.json'):
--> 137             exportTranscriptFile(ext)
    138     else:
    139         exportTranscriptFile("." + output_format)

[<ipython-input-8-555bcf62c33a>](https://localhost:8080/#) in exportTranscriptFile(ext)
    125 
    126     def exportTranscriptFile(ext: str):
--> 127         local_path = video_path_local.parent / video_path_local.name.with_suffix(ext)
    128         export_path = drive_whisper_path / video_path_local.name.with_suffix(ext)
    129         shutil.copy(

AttributeError: 'str' object has no attribute 'with_suffix'
lizhuoq commented 8 months ago

I apologize for the mistake in my previous modification. The export function in your original code encounters an error when handling audio files stored in Google Drive, as shown below.

SameFileError                             Traceback (most recent call last)
[<ipython-input-6-b0b35f220bef>](https://localhost:8080/#) in <cell line: 102>()
    137             exportTranscriptFile(ext)
    138     else:
--> 139         exportTranscriptFile("." + output_format)

2 frames
[/usr/lib/python3.10/shutil.py](https://localhost:8080/#) in copyfile(src, dst, follow_symlinks)
    232 
    233     if _samefile(src, dst):
--> 234         raise SameFileError("{!r} and {!r} are the same file".format(src, dst))
    235 
    236     file_size = 0

SameFileError: PosixPath('/content/Lecture 1 Probability and Counting  Statistics 110.srt') and PosixPath('/content/Lecture 1 Probability and Counting  Statistics 110.srt') are the same file

Therefore, I made a minor modification to the export function, as reflected in my latest pull request. Everything is working fine now. Please review.

ArthurFDLR commented 8 months ago

Thanks for raising this issue. I just pushed a fix.