Update README.md
Browse files
README.md
CHANGED
@@ -27,7 +27,7 @@ model-index:
|
|
27 |
|
28 |
# Wav2Vec2-Large-XLSR-53-German
|
29 |
|
30 |
-
Fine-tuned [facebook/wav2vec2-large-xlsr-53](https://huggingface.co/facebook/wav2vec2-large-xlsr-53) on German using 3% of the [Common Voice](https://huggingface.co/datasets/common_voice) dataset.
|
31 |
When using this model, make sure that your speech input is sampled at 16kHz.
|
32 |
|
33 |
## Usage
|
@@ -40,7 +40,7 @@ import torchaudio
|
|
40 |
from datasets import load_dataset
|
41 |
from transformers import Wav2Vec2ForCTC, Wav2Vec2Processor
|
42 |
|
43 |
-
test_dataset = load_dataset("common_voice", "de", split="test[:2%]")
|
44 |
|
45 |
processor = Wav2Vec2Processor.from_pretrained("marcel/wav2vec2-large-xlsr-german-demo") #TODO: replace {model_id} with your model id. The model id consists of {your_username}/{your_modelname}, *e.g.* `elgeish/wav2vec2-large-xlsr-53-arabic`
|
46 |
model = Wav2Vec2ForCTC.from_pretrained("marcel/wav2vec2-large-xlsr-german-demo/") #TODO: replace {model_id} with your model id. The model id consists of {your_username}/{your_modelname}, *e.g.* `elgeish/wav2vec2-large-xlsr-53-arabic`
|
@@ -94,11 +94,11 @@ resampler = torchaudio.transforms.Resample(48_000, 16_000)
|
|
94 |
# Preprocessing the datasets.
|
95 |
# We need to read the aduio files as arrays
|
96 |
def speech_file_to_array_fn(batch):
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
|
103 |
test_dataset = test_dataset.map(speech_file_to_array_fn)
|
104 |
|
|
|
27 |
|
28 |
# Wav2Vec2-Large-XLSR-53-German
|
29 |
|
30 |
+
Fine-tuned [facebook/wav2vec2-large-xlsr-53](https://huggingface.co/facebook/wav2vec2-large-xlsr-53) on German using 3% of the [Common Voice](https://huggingface.co/datasets/common_voice) dataset.
|
31 |
When using this model, make sure that your speech input is sampled at 16kHz.
|
32 |
|
33 |
## Usage
|
|
|
40 |
from datasets import load_dataset
|
41 |
from transformers import Wav2Vec2ForCTC, Wav2Vec2Processor
|
42 |
|
43 |
+
test_dataset = load_dataset("common_voice", "de", split="test[:2%]")
|
44 |
|
45 |
processor = Wav2Vec2Processor.from_pretrained("marcel/wav2vec2-large-xlsr-german-demo") #TODO: replace {model_id} with your model id. The model id consists of {your_username}/{your_modelname}, *e.g.* `elgeish/wav2vec2-large-xlsr-53-arabic`
|
46 |
model = Wav2Vec2ForCTC.from_pretrained("marcel/wav2vec2-large-xlsr-german-demo/") #TODO: replace {model_id} with your model id. The model id consists of {your_username}/{your_modelname}, *e.g.* `elgeish/wav2vec2-large-xlsr-53-arabic`
|
|
|
94 |
# Preprocessing the datasets.
|
95 |
# We need to read the aduio files as arrays
|
96 |
def speech_file_to_array_fn(batch):
|
97 |
+
\\tbatch["sentence"] = re.sub(chars_to_ignore_regex, '', batch["sentence"]).lower()
|
98 |
+
\\tbatch["sentence"] = re.sub('\\\\ß', 'ss', batch["sentence"])
|
99 |
+
\\tspeech_array, sampling_rate = torchaudio.load(batch["path"])
|
100 |
+
\\tbatch["speech"] = resampler(speech_array).squeeze().numpy()
|
101 |
+
\\treturn batch
|
102 |
|
103 |
test_dataset = test_dataset.map(speech_file_to_array_fn)
|
104 |
|