IMvision12 commited on
Commit
99deea9
·
verified ·
1 Parent(s): 78092d2

fix readme.md

Browse files
Files changed (1) hide show
  1. README.md +68 -7
README.md CHANGED
@@ -1,22 +1,83 @@
1
  ---
2
  pipeline_tag: automatic-speech-recognition
3
  license: apache-2.0
 
4
  library_name: kerasformers
5
  tags:
6
  - keras
7
  - kerasformers
8
  - whisper
9
- - tf
10
- - jax
 
 
11
  - pytorch
 
 
12
  ---
13
 
14
- # whisper_medium (Keras 3)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
- Pure-Keras 3 weights for [kerasformers](https://github.com/IMvision12/KerasFormers), mirrored from the GitHub release. License: `apache-2.0`.
 
 
17
 
18
  ```python
19
- from kerasformers.models.whisper import WhisperSpeechToText, WhisperProcessor
20
- model = WhisperSpeechToText.from_weights("whisper_medium")
21
- processor = WhisperProcessor.from_weights("whisper_medium")
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  pipeline_tag: automatic-speech-recognition
3
  license: apache-2.0
4
+ base_model: openai/whisper-medium
5
  library_name: kerasformers
6
  tags:
7
  - keras
8
  - kerasformers
9
  - whisper
10
+ - automatic-speech-recognition
11
+ - audio
12
+ - multilingual
13
+ - arxiv:2212.04356
14
  - pytorch
15
+ - jax
16
+ - tf
17
  ---
18
 
19
+ ## ***See [our collection](https://huggingface.co/collections/kerasformers/whisper-6a6ac856710a03d7d2e207b6) for all versions of Whisper.***
20
+
21
+ # Run Whisper with Keras 3: JAX, PyTorch, or TensorFlow
22
+
23
+ [![GitHub](https://img.shields.io/badge/GitHub-KerasFormers-black?logo=github)](https://github.com/IMvision12/KerasFormers) [![Docs](https://img.shields.io/badge/Docs-Whisper-blue)](https://imvision12.github.io/KerasFormers/whisper/) [![Collection](https://img.shields.io/badge/HF-Whisper%20collection-yellow)](https://huggingface.co/collections/kerasformers/whisper-6a6ac856710a03d7d2e207b6)
24
+
25
+ # kerasformers/whisper_medium
26
+
27
+ Paper: [Robust Speech Recognition via Large-Scale Weak Supervision (arXiv:2212.04356)](https://arxiv.org/abs/2212.04356) · [HF Papers](https://huggingface.co/papers/2212.04356)
28
+
29
+ Whisper is a **multilingual** encoder-decoder ASR model trained on large-scale weak supervision. Use `task="transcribe"` to keep the source language or `task="translate"` to render English. Pass `language=None` to let the model detect the spoken language. Output is cased and punctuated.
30
+
31
+ For more details on the model, please go to the upstream [model card](https://huggingface.co/openai/whisper-medium).
32
+
33
+ Pure-**Keras 3** conversion of [`openai/whisper-medium`](https://huggingface.co/openai/whisper-medium) for [kerasformers](https://github.com/IMvision12/KerasFormers). One implementation runs unmodified on **TensorFlow / Torch / JAX**.
34
 
35
+ This is an **ASR** checkpoint (`WhisperSpeechToText`, 769M).
36
+
37
+ ## ✨ Quick start
38
 
39
  ```python
40
+ import os
41
+ os.environ["KERAS_BACKEND"] = "torch" # or "jax" / "tensorflow"
42
+
43
+ import soundfile as sf
44
+ from kerasformers.models.whisper import (
45
+ WhisperProcessor,
46
+ WhisperSpeechToText,
47
+ )
48
+
49
+ model = WhisperSpeechToText.from_weights("kerasformers/whisper_medium")
50
+ processor = WhisperProcessor.from_weights("kerasformers/whisper_medium")
51
+
52
+ audio, sr = sf.read("your_audio.wav", dtype="float32") # 16 kHz mono
53
+ # task="transcribe" keeps the source language; "translate" -> English.
54
+ text = model.generate(audio, processor, language="en", task="transcribe")
55
+ print(repr(text[0]))
56
  ```
57
+
58
+ Load any Whisper variant the same way with `from_weights("kerasformers/<variant>")`:
59
+
60
+ | Variant | Hub | Notes |
61
+ |---|---|---|
62
+ | `whisper_tiny` | [`kerasformers/whisper_tiny`](https://huggingface.co/kerasformers/whisper_tiny) | 39M |
63
+ | `whisper_base` | [`kerasformers/whisper_base`](https://huggingface.co/kerasformers/whisper_base) | 74M |
64
+ | `whisper_small` | [`kerasformers/whisper_small`](https://huggingface.co/kerasformers/whisper_small) | 244M |
65
+ | `whisper_medium` | [`kerasformers/whisper_medium`](https://huggingface.co/kerasformers/whisper_medium) | 769M |
66
+ | `whisper_large` | [`kerasformers/whisper_large`](https://huggingface.co/kerasformers/whisper_large) | 1.55B |
67
+ | `whisper_large_v2` | [`kerasformers/whisper_large_v2`](https://huggingface.co/kerasformers/whisper_large_v2) | 1.55B |
68
+ | `whisper_large_v3` | [`kerasformers/whisper_large_v3`](https://huggingface.co/kerasformers/whisper_large_v3) | 128 mel bins |
69
+ | `whisper_large_v3_turbo` | [`kerasformers/whisper_large_v3_turbo`](https://huggingface.co/kerasformers/whisper_large_v3_turbo) | 4 decoder layers |
70
+
71
+ ## Tips
72
+
73
+ - Set `KERAS_BACKEND` **before** importing Keras / kerasformers.
74
+ - Prefer `WhisperProcessor.from_weights(...)` so mel bins match the variant (v3 uses 128).
75
+ - Clips are padded to a 30 s window; chunk longer audio yourself.
76
+ - See [Whisper docs](https://imvision12.github.io/KerasFormers/whisper/) and [Loading Weights](https://imvision12.github.io/KerasFormers/loading_weights/).
77
+ - Community / upstream safetensors still work via the `hf:` prefix, e.g. `WhisperSpeechToText.from_weights("hf:openai/whisper-medium")`.
78
+
79
+ ## Special Thanks
80
+
81
+ A huge thank you to the OpenAI Whisper authors for creating and releasing these models.
82
+
83
+ License: Apache 2.0.