| 157 | #define VALUE_REPR_SAME(name) VALUE_REPR(#name, name) |
| 158 | |
| 159 | std::string Params::to_string() const { |
| 160 | std::ostringstream os; |
| 161 | os << "Params("; |
| 162 | switch (fp->strategy) { |
| 163 | case WHISPER_SAMPLING_GREEDY: |
| 164 | os << "strategy=WHISPER_SAMPLING_GREEDY, " |
| 165 | << "greedy={" |
| 166 | << "best_of=" << std::to_string(fp->greedy.best_of) << "}, "; |
| 167 | break; |
| 168 | case WHISPER_SAMPLING_BEAM_SEARCH: |
| 169 | os << "strategy=WHISPER_SAMPLING_BEAM_SEARCH, " |
| 170 | << "beam_search={" |
| 171 | << "patience=" << std::to_string(fp->beam_search.patience) << ", " |
| 172 | << "beam_size=" << std::to_string(fp->beam_search.beam_size) |
| 173 | << "}, "; |
| 174 | break; |
| 175 | } |
| 176 | os << "language='" << fp->language << "', "; |
| 177 | VALUE_REPR("num_threads", n_threads); |
| 178 | VALUE_REPR("num_max_text_ctx", n_max_text_ctx); |
| 179 | VALUE_REPR_SAME(offset_ms); |
| 180 | VALUE_REPR_SAME(duration_ms); |
| 181 | VALUE_REPR_SAME(translate); |
| 182 | VALUE_REPR_SAME(no_context); |
| 183 | VALUE_REPR_SAME(single_segment); |
| 184 | VALUE_REPR_SAME(print_special); |
| 185 | VALUE_REPR_SAME(print_progress); |
| 186 | VALUE_REPR_SAME(print_realtime); |
| 187 | VALUE_REPR_SAME(print_timestamps); |
| 188 | VALUE_REPR_SAME(token_timestamps); |
| 189 | VALUE_REPR("timestamp_token_probability_threshold", thold_pt); |
| 190 | VALUE_REPR("timestamp_token_sum_probability_threshold", thold_ptsum); |
| 191 | VALUE_REPR("max_segment_length", max_len); |
| 192 | VALUE_REPR_SAME(split_on_word); |
| 193 | VALUE_REPR_SAME(max_tokens); |
| 194 | VALUE_REPR_SAME(speed_up); |
| 195 | VALUE_REPR_SAME(audio_ctx); |
| 196 | os << "prompt_tokens=" << fp->prompt_tokens << ", "; |
| 197 | VALUE_REPR("promp_num_tokens", prompt_n_tokens); |
| 198 | VALUE_REPR_SAME(suppress_blank); |
| 199 | VALUE_REPR_SAME(suppress_non_speech_tokens); |
| 200 | VALUE_REPR_SAME(temperature); |
| 201 | VALUE_REPR("max_initial_timestamps", max_initial_ts); |
| 202 | VALUE_REPR_SAME(length_penalty); |
| 203 | VALUE_REPR_SAME(temperature_inc); |
| 204 | VALUE_REPR("entropy_threshold", entropy_thold); |
| 205 | VALUE_REPR("logprob_threshold", logprob_thold); |
| 206 | os << "no_speech_threshold=" << fp->no_speech_thold << ")"; |
| 207 | return os.str(); |
| 208 | } |
| 209 | |
| 210 | typedef std::function<void(Context &, int, py::object &)> NewSegmentCallback; |
| 211 | |