zackees / transcribe-anything

Input a local file or url and this service will transcribe it using Whisper AI. Completely private and Free 🤯🤯🤯
MIT License
419 stars 34 forks source link

Not able to use transcribe-anything on google colab #14

Closed sayondeep closed 5 months ago

sayondeep commented 5 months ago
from transcribe_anything.api import transcribe

transcribe(

    url_or_file="/content/drive/MyDrive/PMS/PMS_6jan_630.ts",
    output_dir="/content/drive/MyDrive/PMS/text/6jan/630/",
    device="insane",
)

On using the api I am getting the following error: /usr/lib/python3.10/json/decoder.py in raw_decode(self, s, idx) 353 obj, end = self.scan_once(s, idx) 354 except StopIteration as err: --> 355 raise JSONDecodeError("Expecting value", s, err.value) from None 356 return obj, end

JSONDecodeError: Expecting value: line 1 column 1 (char 0)

sayondeep commented 5 months ago

full error log:

Downloading https://github.com/zackees/ffmpeg_bins/raw/main/v5.0/linux.zip -> /usr/local/lib/python3.10/dist-packages/static_ffmpeg/bin/linux.zip ............................................................................................................................................................................................................................................................................................................................................................................................................................................ Download of https://github.com/zackees/ffmpeg_bins/raw/main/v5.0/linux.zip -> /usr/local/lib/python3.10/dist-packages/static_ffmpeg/bin/linux.zip completed. Extracting /usr/local/lib/python3.10/dist-packages/static_ffmpeg/bin/linux.zip -> /usr/local/lib/python3.10/dist-packages/static_ffmpeg/bin making dir /content/drive/MyDrive/PMS/text/6jan/630/ Running: ffmpeg -y -i "/content/drive/MyDrive/PMS/PMS_6jan_630.ts" -acodec pcm_s16le -ar 44100 -ac 1 out.wav ##################################### ####### INSANE GPU MODE! ############ ##################################### Using device insane Running whisper on /tmp/tmpltebhjtd.wav (will install models on first run) Virtual environment 'insanely_fast_whisper' created at /usr/local/lib/python3.10/dist-packages/transcribe_anything/venv/insanely_fast_whisper Running: pip install openai-whisper Running: pip install insanely-fast-whisper Running: pip install torch==2.1.2+cu121 --extra-index-url https://download.pytorch.org/whl/cu121 Running: pip install srtranslator==0.2.6

JSONDecodeError Traceback (most recent call last) in <cell line: 3>() 1 from transcribe_anything.api import transcribe 2 ----> 3 transcribe( 4 5 url_or_file="/content/drive/MyDrive/PMS/PMS_6jan_630.ts",

7 frames /usr/local/lib/python3.10/dist-packages/transcribe_anything/api.py in transcribe(url_or_file, output_dir, model, task, language, device, embed, hugging_face_token, other_args) 202 with tempfile.TemporaryDirectory() as tmpdir: 203 if device_enum == Device.INSANE: --> 204 run_insanely_fast_whisper( 205 input_wav=Path(tmp_wav), 206 model=model_str,

/usr/local/lib/python3.10/dist-packages/transcribe_anything/insanely_fast_whisper.py in run_insanely_fast_whisper(input_wav, model, output_dir, task, language, hugging_face_token, other_args) 196 """Runs insanely fast whisper.""" 197 env = get_environment() --> 198 device_id = get_device_id() 199 cmd_list = [] 200 output_dir.mkdir(parents=True, exist_ok=True)

/usr/local/lib/python3.10/dist-packages/transcribe_anything/insanely_fast_whisper.py in get_device_id() 88 if sys.platform == "darwin": 89 return "mps" ---> 90 cuda_info = get_cuda_info() 91 if not cuda_info.cuda_available: 92 raise ValueError("CUDA is not available.")

/usr/local/lib/python3.10/dist-packages/transcribe_anything/insanely_fast_whisper.py in get_cuda_info() 79 ) 80 stdout = cp.stdout ---> 81 CUDA_INFO = CudaInfo.from_json_str(stdout) 82 return CUDA_INFO 83

/usr/local/lib/python3.10/dist-packages/transcribe_anything/cuda_available.py in from_json_str(json_str) 64 def from_json_str(json_str: str) -> "CudaInfo": 65 """Loads from json str and returns a CudaInfo object.""" ---> 66 data = json.loads(json_str) 67 cuda_devices_data = data.get("cuda_devices", []) 68 cuda_devices = [CudaDevice(**device) for device in cuda_devices_data]

/usr/lib/python3.10/json/init.py in loads(s, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw) 344 parse_int is None and parse_float is None and 345 parse_constant is None and object_pairs_hook is None and not kw): --> 346 return _default_decoder.decode(s) 347 if cls is None: 348 cls = JSONDecoder

/usr/lib/python3.10/json/decoder.py in decode(self, s, _w) 335 336 """ --> 337 obj, end = self.raw_decode(s, idx=_w(s, 0).end()) 338 end = _w(s, end).end() 339 if end != len(s):

/usr/lib/python3.10/json/decoder.py in raw_decode(self, s, idx) 353 obj, end = self.scan_once(s, idx) 354 except StopIteration as err: --> 355 raise JSONDecodeError("Expecting value", s, err.value) from None 356 return obj, end

JSONDecodeError: Expecting value: line 1 column 1 (char 0)

zackees commented 5 months ago

Thanks for this, I'll look into this now

zackees commented 5 months ago

Can you make a public collab for me to test? I can't reproduce the error (yet). It looks like the subprocess to get the cuda information is not returning the expected string, but instead returning None, which causes the json parser to barf.

zackees commented 5 months ago

Also, I see that in your isolated-environment it is loading srtranslator. This indicates you are running an older transcribe-anything version, as the newer versions move this out to it's own dependency. Can you try upgrading using pip install -U transcribe-anything

zackees commented 5 months ago

Never mind, I was able to reproduce it on linux. It's an error with isolated environment. I'll try and fix.

zackees commented 5 months ago

Okay, fix has been issued. Please upgrade transcribe-anything via pip install -U transcribe-anything