Skip to content

Commit

Permalink
Update version to 2.7.35 & use static_ffmpeg commands
Browse files Browse the repository at this point in the history
  • Loading branch information
zackees committed Apr 29, 2024
1 parent eac41e5 commit 623eb25
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 11 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ is closed then to get back into the environment `cd transcribe_anything` and exe
* Every commit is tested for standard linters and a batch of unit tests.

# Versions
* 2.7.35: All `ffmpeg` commands are now `static_ffmpeg` commands. Fixes issue.
* 2.7.34: Various fixes.
* 2.7.33: Fixes linux
* 2.7.32: Fixes mac m1 and m2.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
EMAIL = "dont@email.me"
AUTHOR = "Zach Vorhies"
REQUIRES_PYTHON = ">=3.10.0"
VERSION = "2.7.34"
VERSION = "2.7.35"

# The text of the README file
with open(os.path.join(HERE, "README.md"), encoding="utf-8", mode="r") as fd:
Expand Down
6 changes: 1 addition & 5 deletions transcribe_anything/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from typing import Optional

from appdirs import user_config_dir # type: ignore
from static_ffmpeg import add_paths as ffmpeg_add_paths # type: ignore

from transcribe_anything.audio import fetch_audio
from transcribe_anything.insanely_fast_whisper import run_insanely_fast_whisper
Expand Down Expand Up @@ -77,9 +76,6 @@ def from_str(device: str) -> "Device":
raise ValueError(f"Unknown device {device}")


ffmpeg_add_paths()


def make_temp_wav() -> str:
"""
Makes a temporary mp3 file and returns the path to it.
Expand Down Expand Up @@ -293,7 +289,7 @@ def transcribe(
assert os.path.isfile(url_or_file), f"Path {url_or_file} doesn't exist."
out_mp4 = os.path.join(output_dir, "out.mp4")
embed_ffmpeg_cmd_list = [
"ffmpeg",
"static_ffmpeg",
"-y",
"-i",
url_or_file,
Expand Down
7 changes: 2 additions & 5 deletions transcribe_anything/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import sys
import tempfile

import static_ffmpeg # type: ignore

from transcribe_anything.util import PROCESS_TIMEOUT
from transcribe_anything.ytldp_download import ytdlp_download

Expand All @@ -27,7 +25,7 @@ def _convert_to_wav(
tmpwav.close()
tmpwavepath = tmpwav.name
audio_encoder = "-acodec pcm_s16le -ar 44100 -ac 1"
cmd = f'ffmpeg -y -i "{inpath}" {cmd_audio_filter} {audio_encoder} "{tmpwavepath}"'
cmd = f'static_ffmpeg -y -i "{inpath}" {cmd_audio_filter} {audio_encoder} "{tmpwavepath}"'
print(f"Running:\n {cmd}")
try:
subprocess.run(
Expand All @@ -48,7 +46,6 @@ def _convert_to_wav(
def fetch_audio(url_or_file: str, out_wav: str) -> None:
"""Fetches from the internet or from a local file and outputs a wav file."""
assert out_wav.endswith(".wav")
static_ffmpeg.add_paths() # pylint: disable=no-member
if url_or_file.startswith("http") or url_or_file.startswith("ftp"):
with tempfile.TemporaryDirectory() as tmpdir:
print(f"Using temporary directory {tmpdir}")
Expand All @@ -62,7 +59,7 @@ def fetch_audio(url_or_file: str, out_wav: str) -> None:
abspath = os.path.abspath(url_or_file)
out_wav_abs = os.path.abspath(out_wav)
with tempfile.TemporaryDirectory() as tmpdir:
cmd = f'ffmpeg -y -i "{abspath}" -acodec pcm_s16le -ar 44100 -ac 1 out.wav'
cmd = f'static_ffmpeg -y -i "{abspath}" -acodec pcm_s16le -ar 44100 -ac 1 out.wav'
sys.stderr.write(f"Running:\n {cmd}\n")
subprocess.run(
cmd,
Expand Down

0 comments on commit 623eb25

Please sign in to comment.