Skip to content

Commit

Permalink
Fix transcription worker to handle bot detection.
Browse files Browse the repository at this point in the history
See JuanBindez/pytubefix#209

Also up the TFLOPS to avoid fp16 incapable GPUs and then
use the large-v3-turbo model for smaller size and faster
inference.
  • Loading branch information
awong-dev committed Jan 29, 2025
1 parent 0657726 commit 50fa067
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,4 @@ jobs:

- name: Deploy Functions
if: ${{ inputs.deploy-functions != '' }}
run: npm --prefix functions deploy -P ${{ inputs.deploy-functions }}
run: npm --prefix functions run deploy -P ${{ inputs.deploy-functions }}
2 changes: 1 addition & 1 deletion functions-python/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def start_transcribe(
storage=DISK_GB,
order="dph_total",
query=('cpu_cores_effective>=10 cpu_ram>=32 gpu_total_ram>=8 '
'reliability>=0.95 dph<2 total_flops>=10'))
'reliability>=0.95 dph<2 total_flops>=12'))
cheapest = json.loads(offers_json)[0]
print(f"cheapest ask id {cheapest['ask_contract_id']} cost "
f"{json.dumps(cheapest)}")
Expand Down
9 changes: 7 additions & 2 deletions tools/process_new_vids/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@ COPY prime_model.mp4 /workspace/app/
RUN apt-get -y update && \
apt-get -y install git ffmpeg && \
pip install git+https://github.com/m-bain/whisperx.git && \
whisperx --model=large-v3 --language=en --thread=4 --hf_token=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 --diarize --output_form=json --compute_type=int8 --output_dir=/tmp -- prime_model.mp4
whisperx --model=large-v3-turbo --language=en --thread=4 --hf_token=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 --diarize --output_form=json --compute_type=int8 --output_dir=/tmp -- prime_model.mp4

RUN pip install vastai

COPY requirements.txt /workspace/app/
RUN pip install -r requirements.txt
RUN pip install -r requirements.txt

RUN <<EOF
apt-get -y install curl unzip
curl -fsSL https://fnm.vercel.app/install | bash
~/.local/share/fnm/fnm install --lts
EOF

COPY transcribe_worker.py lysine_protocol.sh onstart_hook.sh /workspace/app/
RUN chmod 755 /workspace/app/transcribe_worker.py /workspace/app/lysine_protocol.sh /workspace/app/onstart_hook.sh
5 changes: 5 additions & 0 deletions tools/process_new_vids/onstart_hook.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#!/bin/bash

export PATH=${HOME}/.local/share/fnm:$PATH

eval "$(fnm env --use-on-cd --shell bash)"
fnm use lts/latest

# Default to giving 10 mins on failure.
/workspace/app/lysine_protocol.sh "${3-:30}" & python /workspace/app/transcribe_worker.py -w /tmp/transcribe -t "${1:-4}" -x "$2" -m large-v3 -c -s; /workspace/app/lysine_protocol.sh "${4:-10}"
2 changes: 1 addition & 1 deletion tools/process_new_vids/transcribe_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def main():
required=True)
parser.add_argument('-m', '--model', dest='model', metavar="MODEL",
type=str, help='Downloads whisper MODEL',
default="large-v3")
default="large-v3-turbo")
parser.add_argument('--compute_type', dest='compute_type',
metavar="COMPUTE_TYPE", type=str,
help='The compute type to use', default="float16")
Expand Down

0 comments on commit 50fa067

Please sign in to comment.