-
Notifications
You must be signed in to change notification settings - Fork 158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
whisperX to create transcripts #28
Open
JvSdv
wants to merge
14
commits into
ThioJoe:main
Choose a base branch
from
JvSdv:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+64
−2
Open
Changes from 7 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
7286923
whisperx init
JvSdv 8eed0b8
video location
JvSdv 4d8fc0d
Merge branch 'main' of https://github.com/JvSdv/Auto-Synced-Translate…
JvSdv b26881f
separating audio from video and transcribing
JvSdv c72b126
Output folder based on the original videofile name
JvSdv 9f055e8
Optional Whisperx
JvSdv 3862301
Merge branch 'main' of https://github.com/JvSdv/Auto-Synced-Translate…
JvSdv 06a6db5
print output, and remove video folder output
JvSdv 55db431
remove re import
JvSdv b3c066b
verify if the transcription is done
JvSdv 4f9e6cd
Video anywhere and Variables
JvSdv 3004db5
update readme and requirements
JvSdv e1e0a4c
Merge branch 'main' into main
JvSdv d395401
Merge branch 'ThioJoe:main' into main
JvSdv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,6 +72,11 @@ | |
originalVideoFile = os.path.abspath(batchConfig['SETTINGS']['original_video_file_path'].strip("\"")) | ||
srtFile = os.path.abspath(batchConfig['SETTINGS']['srt_file_path'].strip("\"")) | ||
|
||
# Create the output folder based on the original video file name | ||
fileName = os.path.basename(originalVideoFile).split(".")[0] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't this the same as the code in Also, there's already some code to handle the creation of output folders in Line 479 of the main file, in my opinion, moving this implementation there (or replacing the existing one) would be a better fit for this code. |
||
fileName = re.sub(r"[^\w\s-]", "", fileName) | ||
outputFolder = outputFolder + "/" + fileName | ||
|
||
# Validate the number of sections | ||
for num in languageNums: | ||
# Check if section exists | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import re | ||
import subprocess | ||
import os | ||
import configparser | ||
|
||
#---------------------------------------- Batch File Processing ---------------------------------------- | ||
batchConfig = configparser.ConfigParser() | ||
batchConfig.read('batch.ini') | ||
|
||
# MOVE THIS INTO A VARIABLE AT SOME POINT | ||
outputFolder = "output" | ||
|
||
# Get the video file name Create the output folder based on the original video file name | ||
originalVideoFile = os.path.abspath(batchConfig['SETTINGS']['original_video_file_path'].strip("\"")) | ||
|
||
#whisperx (Whisper-Based Automatic Speech Recognition (ASR) with improved timestamp accuracy using forced alignment) | ||
def transcribe(videoFile, output): | ||
#Catch the video file name and create a folder with the same name | ||
fileName = os.path.basename(videoFile).split(".")[0] | ||
fileName = re.sub(r"[^\w\s-]", "", fileName) #Remove special characters | ||
outputFolder = output + "/" + fileName | ||
|
||
#Create the output folder | ||
if not os.path.exists(outputFolder): | ||
os.makedirs(outputFolder) | ||
|
||
#Extract the audio from the original video to wav and save it in the output/{original_video_name} | ||
command = f"ffmpeg -i {videoFile} -vn -acodec pcm_s16le -ac 1 -ar 48000 -f wav {outputFolder}/original.wav" | ||
subprocess.call(command, shell=True) | ||
|
||
#If you want to install whisperx in another environment, use conda envs | ||
#os.system(f"conda activate whisperx && whisperx {outputFolder}/original.wav --model small.en --align_model WAV2VEC2_ASR_LARGE_LV60K_960H --output_dir {outputFolder}") | ||
#Run whisperx | ||
os.system(f"whisperx {outputFolder}/original.wav --model small.en --align_model WAV2VEC2_ASR_LARGE_LV60K_960H --output_dir {outputFolder}") | ||
|
||
transcribe(originalVideoFile, outputFolder) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see some calls to the settings file with
original_video_file_path
, however, the config file remains unchanged, I think that creating a commit with these new settings and a default value would avoid some unexpected behavior on users that do not look into the codeThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's best to remove this for now