Daporte commited on
Commit
c3e6eff
·
verified ·
1 Parent(s): d2dc799

Upload configuration_prosody.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. configuration_prosody.py +68 -0
configuration_prosody.py ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Configuration for the prosody-to-text pipeline."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from transformers import PretrainedConfig
6
+
7
+
8
+ class ProsodyToTextConfig(PretrainedConfig):
9
+ """Everything needed to rebuild the pipeline.
10
+
11
+ The mel contract is the part that matters. `mel_bins` and `length_ratio`
12
+ must match what the conformer was trained with: the loader falls back to
13
+ defaults when they are absent, and a wrong `length_ratio` mis-times the
14
+ mel against the audio without failing, which is the worst way for it to
15
+ be wrong.
16
+ """
17
+
18
+ model_type = "prosody_to_text"
19
+
20
+ def __init__(
21
+ self,
22
+ # --- the conformer's mel contract -------------------------------
23
+ mel_bins: int = 12,
24
+ length_ratio: float = 0.5,
25
+ conformer_subfolder: str = "conformer",
26
+ # --- feature extraction -----------------------------------------
27
+ # 200 Hz, and the physical-range normalisation the conformer was
28
+ # trained with. These mirror the training preprocessor; changing one
29
+ # without the others silently moves the model off its own
30
+ # distribution.
31
+ feature_rate_hz: float = 200.0,
32
+ f0_scale: float = 500.0,
33
+ intensity_scale: float = 100.0,
34
+ # --- the decoder -------------------------------------------------
35
+ whisper_subfolder: str = "whisper",
36
+ tokenizer_subfolder: str = "tokenizer",
37
+ # Ten, matching the published inference runs. Wider was tried and
38
+ # made the transcriptions worse: on a signal this weak a wider beam
39
+ # searches harder for the highest-likelihood sequence, which is the
40
+ # caption boilerplate the checkpoint overlearned.
41
+ num_beams: int = 10,
42
+ language: str = "en",
43
+ no_repeat_ngram_size: int = 3,
44
+ max_new_tokens: int = 225,
45
+ # On, matching the dataset runs the published numbers come from: ban
46
+ # numerals, and take the token budget from the utterance's own
47
+ # duration rather than a flat limit. Set False to decode
48
+ # unconstrained, which is what the drawing demo does.
49
+ constrain: bool = True,
50
+ **kwargs,
51
+ ) -> None:
52
+ self.mel_bins = mel_bins
53
+ self.length_ratio = length_ratio
54
+ self.conformer_subfolder = conformer_subfolder
55
+
56
+ self.feature_rate_hz = feature_rate_hz
57
+ self.f0_scale = f0_scale
58
+ self.intensity_scale = intensity_scale
59
+
60
+ self.whisper_subfolder = whisper_subfolder
61
+ self.tokenizer_subfolder = tokenizer_subfolder
62
+ self.num_beams = num_beams
63
+ self.language = language
64
+ self.no_repeat_ngram_size = no_repeat_ngram_size
65
+ self.max_new_tokens = max_new_tokens
66
+ self.constrain = constrain
67
+
68
+ super().__init__(**kwargs)