Skip to content

Commit

Permalink
Added noise suppression and fixed whisper v3 issues
Browse files Browse the repository at this point in the history
  • Loading branch information
tmoroney committed Nov 26, 2024
1 parent 9fa13b0 commit e9ebfe9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions AutoSubs-App/src/GlobalContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export function GlobalProvider({ children }: React.PropsWithChildren<{}>) {
const [translate, setTranslate] = useState(false);
const [diarize, setDiarize] = useState(false);
const [maxWords, setMaxWords] = useState(6);
const [maxChars, setMaxChars] = useState(30);
const [maxChars, setMaxChars] = useState(25);
const [markIn, setMarkIn] = useState(0);

async function getFullTranscriptPath() {
Expand Down Expand Up @@ -149,7 +149,7 @@ export function GlobalProvider({ children }: React.PropsWithChildren<{}>) {
setTranslate(result.storedTranslate || false);
setDiarize(result.storedDiarize || false);
setMaxWords(result.storedMaxWords || 6);
setMaxChars(result.storedMaxChars || 30);
setMaxChars(result.storedMaxChars || 25);
}).catch((error) => {
console.error("Error initializing state:", error);
});
Expand Down
9 changes: 4 additions & 5 deletions Mac-Server/transcription-server.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@ def __getattr__(self, attr):
"base": "mlx-community/whisper-base-mlx-q4",
"small": "mlx-community/whisper-small-mlx",
"medium": "mlx-community/whisper-medium-mlx",
"large": "mlx-community/whisper-large-v3-turbo",
"large": "mlx-community/distil-whisper-large-v3",
}

english_models = {
"tiny": "mlx-community/whisper-tiny.en-mlx",
"base": "mlx-community/whisper-base.en-mlx",
"small": "mlx-community/whisper-small.en-mlx",
"medium": "mlx-community/whisper-medium.en-mlx",
"large": "mlx-community/whisper-large-v3-turbo",
"large": "mlx-community/distil-whisper-large-v3",
}

def is_model_cached_locally(model_id, revision=None):
Expand Down Expand Up @@ -152,14 +152,13 @@ def inference(audio, **kwargs) -> dict:
language=kwargs["language"],
verbose=True,
task=kwargs["task"]

)
# Ensure segments are sorted
output["segments"] = sorted(output["segments"], key=lambda x: x["start"])
return output

def transcribe_audio(audio_file, kwargs, max_words, max_chars):
print("Starting transcription...")
whisperResult = stable_whisper.transcribe_any(inference, audio_file, inference_kwargs = kwargs, vad=False)
whisperResult = stable_whisper.transcribe_any(inference, audio_file, inference_kwargs = kwargs, vad=True, only_voice_freq=True, force_order=True)
whisperResult.split_by_length(max_words=max_words, max_chars=max_chars)
return whisperResult.to_dict()

Expand Down

0 comments on commit e9ebfe9

Please sign in to comment.