Skip to main content

rimelabs_api/generated/
rime.rs

1// This file is @generated by prost-build.
2#[derive(Clone, PartialEq, ::prost::Message)]
3pub struct StreamingSynthesisRequest {
4    #[prost(oneof = "streaming_synthesis_request::Payload", tags = "1, 2")]
5    pub payload: ::core::option::Option<streaming_synthesis_request::Payload>,
6}
7/// Nested message and enum types in `StreamingSynthesisRequest`.
8pub mod streaming_synthesis_request {
9    #[derive(Clone, PartialEq, ::prost::Oneof)]
10    pub enum Payload {
11        /// FIRST message only: all synthesis parameters. Its `text` field may carry
12        /// the first complete sentence or be left empty.
13        #[prost(message, tag = "1")]
14        Header(super::SynthesisRequest),
15        /// Subsequent messages: one complete sentence to append to the live
16        /// synthesis.
17        #[prost(string, tag = "2")]
18        TextChunk(::prost::alloc::string::String),
19    }
20}
21#[derive(Clone, PartialEq, ::prost::Message)]
22pub struct SynthesisRequest {
23    /// BCP-47 language tag, e.g. "en".
24    /// Used to route the frontend pipeline and set backend language.
25    #[prost(string, optional, tag = "2")]
26    pub language: ::core::option::Option<::prost::alloc::string::String>,
27    /// Speaker name, e.g. "luna".
28    #[prost(string, optional, tag = "3")]
29    pub speaker: ::core::option::Option<::prost::alloc::string::String>,
30    /// Text to synthesize.
31    #[prost(string, tag = "4")]
32    pub text: ::prost::alloc::string::String,
33    #[prost(message, optional, tag = "5")]
34    pub audio_parameters: ::core::option::Option<AudioParameters>,
35    /// Controls how input text is split before synthesis.
36    /// Defaults to SPLIT_STRATEGY_SENTENCE when unset.
37    #[prost(enumeration = "SplitStrategy", optional, tag = "6")]
38    pub split_strategy: ::core::option::Option<i32>,
39    #[prost(message, optional, tag = "8")]
40    pub coda_parameters: ::core::option::Option<CodaParameters>,
41    #[prost(message, optional, tag = "9")]
42    pub mist_parameters: ::core::option::Option<MistParameters>,
43    /// Timestamps of the spoken spans of the synthesized audio, delivered in
44    /// the trailer once the audio has drained. Off unless requested.
45    #[prost(message, optional, tag = "10")]
46    pub timestamps: ::core::option::Option<TimestampOptions>,
47    /// Per-request pronunciation overrides. Validated against the request
48    /// language's phonology (an ill-formed entry fails the request) and applied by
49    /// the segmenter and the pronunciation stages. See
50    /// engine/src/pipeline/pronunciation.rs.
51    #[prost(message, repeated, tag = "11")]
52    pub custom_lexicon: ::prost::alloc::vec::Vec<PronunciationEntry>,
53}
54/// One custom-lexicon pronunciation override. The neural backend speaks
55/// `spelling` (matched case-insensitively as a whole word) using `pronunciation`
56/// wherever it occurs in the request text.
57#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
58pub struct PronunciationEntry {
59    /// The word to override, e.g. "cache".
60    #[prost(string, tag = "1")]
61    pub spelling: ::prost::alloc::string::String,
62    /// Its X-SAMPA pronunciation, e.g. `" k { S` (primary stress, then phones).
63    #[prost(string, tag = "2")]
64    pub pronunciation: ::prost::alloc::string::String,
65}
66#[derive(Clone, PartialEq, ::prost::Message)]
67pub struct SynthesisResponseStream {
68    #[prost(oneof = "synthesis_response_stream::Payload", tags = "1, 2")]
69    pub payload: ::core::option::Option<synthesis_response_stream::Payload>,
70}
71/// Nested message and enum types in `SynthesisResponseStream`.
72pub mod synthesis_response_stream {
73    #[derive(Clone, PartialEq, ::prost::Oneof)]
74    pub enum Payload {
75        /// A chunk of encoded audio, in the format requested.
76        #[prost(bytes, tag = "1")]
77        Audio(::prost::alloc::vec::Vec<u8>),
78        /// Sent once, after the last audio chunk, when the request asked for
79        /// anything it carries. A request that asked for nothing sees no trailer.
80        #[prost(message, tag = "2")]
81        Trailer(super::SynthesisResponseTrailer),
82    }
83}
84/// Results that settle only once the audio has drained.
85#[derive(Clone, PartialEq, ::prost::Message)]
86pub struct SynthesisResponseTrailer {
87    /// Present when `timestamps.enable` was set.
88    #[prost(message, optional, tag = "1")]
89    pub timestamps: ::core::option::Option<Timestamps>,
90}
91#[derive(Clone, PartialEq, ::prost::Message)]
92pub struct AudioParameters {
93    /// Equivalent to the HTTP `Accept` header.
94    /// Examples: "audio/wav", "audio/mpeg", "audio/ogg;codecs=opus", "audio/l16".
95    #[prost(string, optional, tag = "1")]
96    pub audio_format: ::core::option::Option<::prost::alloc::string::String>,
97    #[prost(int32, optional, tag = "2")]
98    pub sampling_rate: ::core::option::Option<i32>,
99    #[prost(float, optional, tag = "3")]
100    pub time_scale_factor: ::core::option::Option<f32>,
101}
102#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
103pub struct CodaParameters {
104    /// Streaming text input (`SynthesizeStreaming` / WebSocket `text`) only:
105    /// number of leading text tokens prefilled as a lookahead block so the first
106    /// audio frames have content context. Higher values improve content
107    /// robustness at the start of the utterance but delay the first audio until
108    /// that many text tokens have arrived. Clamped to the tokens available when
109    /// generation starts. Defaults to 0, which reproduces upstream Qwen3-TTS's
110    /// exact streaming layout. Ignored for one-shot synthesis (which always sees
111    /// the complete text up front).
112    #[prost(int32, optional, tag = "8")]
113    pub text_lookahead_tokens: ::core::option::Option<i32>,
114}
115#[derive(Clone, PartialEq, ::prost::Message)]
116pub struct MistParameters {
117    #[prost(bool, optional, tag = "1")]
118    pub pause_between_brackets: ::core::option::Option<bool>,
119    #[prost(bool, optional, tag = "2")]
120    pub phonemize_between_brackets: ::core::option::Option<bool>,
121    #[prost(float, repeated, tag = "3")]
122    pub inline_time_scale_factors: ::prost::alloc::vec::Vec<f32>,
123    #[prost(bool, optional, tag = "4")]
124    pub save_oovs: ::core::option::Option<bool>,
125}
126#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
127pub struct TimestampOptions {
128    /// Report a SpanTimestamp for every spoken span. Costs one aligner
129    /// inference per request; never delays or fails the audio.
130    #[prost(bool, tag = "1")]
131    pub enable: bool,
132}
133/// One span of the text the talker spoke, as the aligner segments it: a
134/// whitespace-separated word of the request text after normalization (so
135/// numbers and abbreviations appear spelled out), or a morpheme for a
136/// language written without spaces.
137#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
138pub struct SpanTimestamp {
139    #[prost(string, tag = "1")]
140    pub text: ::prost::alloc::string::String,
141    /// Offsets from the start of the synthesized audio, at the audio's native
142    /// rate and before `time_scale_factor`.
143    #[prost(message, optional, tag = "2")]
144    pub start: ::core::option::Option<::pbjson_types::Duration>,
145    #[prost(message, optional, tag = "3")]
146    pub end: ::core::option::Option<::pbjson_types::Duration>,
147}
148/// The timestamps of one synthesis, delivered once after all audio: on gRPC
149/// as `trailer.timestamps`, on WebSocket as `done.timestamps`. Absent when
150/// the request did not ask for them. A non-OK status never fails the
151/// synthesis that produced the audio.
152#[derive(Clone, PartialEq, ::prost::Message)]
153pub struct Timestamps {
154    /// How the alignment settled, with `code` a google.rpc.Code. `OK` carries
155    /// spans; every other code carries none, with the reason in `message`:
156    /// INVALID_ARGUMENT     the aligner does not support the request's
157    /// language, or rejected the utterance;
158    /// RESOURCE_EXHAUSTED   the utterance exceeds what the aligner accepts,
159    /// or the branch lost input under load;
160    /// DEADLINE_EXCEEDED    the aligner did not answer within its budget;
161    /// UNAVAILABLE          the aligner worker is not serving;
162    /// UNIMPLEMENTED        this package has no aligner;
163    /// CANCELLED            synthesis ended before alignment settled.
164    #[prost(message, optional, tag = "1")]
165    pub status: ::core::option::Option<super::google::rpc::Status>,
166    #[prost(message, repeated, tag = "2")]
167    pub spans: ::prost::alloc::vec::Vec<SpanTimestamp>,
168}
169#[derive(Clone, PartialEq, ::prost::Message)]
170pub struct NormalizeTextRequest {
171    /// Text to normalize.
172    #[prost(string, tag = "1")]
173    pub text: ::prost::alloc::string::String,
174    /// BCP-47 language tag, e.g. "en".
175    #[prost(string, optional, tag = "2")]
176    pub language: ::core::option::Option<::prost::alloc::string::String>,
177    /// Per-request pronunciation overrides; same shape and validation as on
178    /// SynthesisRequest.
179    #[prost(message, repeated, tag = "3")]
180    pub custom_lexicon: ::prost::alloc::vec::Vec<PronunciationEntry>,
181}
182#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
183pub struct NormalizeTextResponse {
184    /// Deprecated: use normalized_sentences. Sentences are concatenated with no
185    /// whitespace separator, so multi-sentence inputs come back glued together.
186    #[prost(string, tag = "1")]
187    pub normalized_text: ::prost::alloc::string::String,
188    /// The normalized text, one entry per sentence emitted by the frontend
189    /// pipeline. Each entry is already trimmed; join with a single space to
190    /// reconstruct display text.
191    #[prost(string, repeated, tag = "2")]
192    pub normalized_sentences: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
193}
194/// Empty for now, but used instead of google.protobuf.Empty for extensibility.
195#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
196pub struct GetSupportedLanguagesRequest {}
197#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
198pub struct GetSupportedLanguagesResponse {
199    /// List of supported BCP-47 language tags.
200    #[prost(string, repeated, tag = "1")]
201    pub languages: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
202}
203#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
204pub struct GetSupportedSpeakersRequest {
205    #[prost(string, optional, tag = "1")]
206    pub language: ::core::option::Option<::prost::alloc::string::String>,
207}
208#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
209pub struct GetSupportedSpeakersResponse {
210    /// List of supported speaker names for the given language.
211    #[prost(string, repeated, tag = "1")]
212    pub speakers: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
213}
214/// Client -> server. Exactly one message per WebSocket frame.
215#[derive(Clone, PartialEq, ::prost::Message)]
216pub struct WebSocketRequest {
217    /// Client-chosen context identifier, at most 128 bytes. Empty selects the
218    /// context named "default". An identifier may be reused after its context
219    /// reaches a terminal event.
220    #[prost(string, tag = "1")]
221    pub context_id: ::prost::alloc::string::String,
222    #[prost(oneof = "web_socket_request::Payload", tags = "2, 3, 4, 5, 6")]
223    pub payload: ::core::option::Option<web_socket_request::Payload>,
224}
225/// Nested message and enum types in `WebSocketRequest`.
226pub mod web_socket_request {
227    #[derive(Clone, PartialEq, ::prost::Oneof)]
228    pub enum Payload {
229        /// Connection-level configuration. At most one, and only before the first
230        /// `start`. Not required in debug mode or when the upgrade request
231        /// carried an `Authorization` header.
232        #[prost(message, tag = "2")]
233        Config(super::WebSocketConfig),
234        /// Opens the context with the full synthesis parameters. A non-empty
235        /// `text` is the complete input for one-shot synthesis: audio streams
236        /// and ends with `done`, no `end` required. An empty `text` opens a
237        /// streaming context that stays open for `text` messages and finalizes
238        /// on `end`.
239        #[prost(message, tag = "3")]
240        Start(super::SynthesisRequest),
241        /// Appends a chunk of input text to an open streaming context (one opened
242        /// with an empty `start.text`). The engine meters, segments, and
243        /// synthesizes it into the same continuous audio as it arrives. Rejected
244        /// with kind "invalid_input" if the context is not open for input (no
245        /// `start`, or already `end`ed / one-shot).
246        #[prost(string, tag = "4")]
247        Text(::prost::alloc::string::String),
248        /// Declares end of input for a streaming context. Remaining audio is
249        /// delivered, followed by `done`. A no-op for a one-shot context. The
250        /// connection stays open for further contexts.
251        #[prost(message, tag = "5")]
252        End(super::WebSocketEnd),
253        /// Aborts the context immediately, discarding in-flight synthesis.
254        /// Acknowledged with `cancelled`; idempotent (cancelling an unknown or
255        /// finished context is not an error).
256        #[prost(message, tag = "6")]
257        Cancel(super::WebSocketCancel),
258    }
259}
260#[derive(Clone, PartialEq, ::prost::Message)]
261pub struct WebSocketConfig {
262    /// Mirrors the HTTP `Authorization` header, e.g. "Api-Key <key>".
263    /// Rejected if the upgrade request already carried an Authorization header.
264    #[prost(string, optional, tag = "1")]
265    pub authorization: ::core::option::Option<::prost::alloc::string::String>,
266    /// License JSON for on-prem deployments; mirrors the `x-rime-license`
267    /// gRPC metadata / the `license` field of the HTTP API.
268    #[prost(string, optional, tag = "2")]
269    pub license: ::core::option::Option<::prost::alloc::string::String>,
270    /// Defaults merged (field-wise, shallow) under every subsequent `start`.
271    /// Its `text` field is ignored.
272    #[prost(message, optional, tag = "3")]
273    pub defaults: ::core::option::Option<SynthesisRequest>,
274}
275#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
276pub struct WebSocketEnd {}
277#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
278pub struct WebSocketCancel {}
279/// Server -> client. Exactly one message per WebSocket frame.
280#[derive(Clone, PartialEq, ::prost::Message)]
281pub struct WebSocketResponse {
282    /// Context the payload applies to. Empty for connection-scoped payloads
283    /// (`ready` and connection-level `error`s).
284    #[prost(string, tag = "1")]
285    pub context_id: ::prost::alloc::string::String,
286    #[prost(oneof = "web_socket_response::Payload", tags = "2, 3, 4, 5, 6, 7")]
287    pub payload: ::core::option::Option<web_socket_response::Payload>,
288}
289/// Nested message and enum types in `WebSocketResponse`.
290pub mod web_socket_response {
291    #[derive(Clone, PartialEq, ::prost::Oneof)]
292    pub enum Payload {
293        /// Sent once per connection when the engine is ready to synthesize
294        /// (pipelines loaded and serving). Gate `start` on this event.
295        #[prost(message, tag = "2")]
296        Ready(super::WebSocketReady),
297        /// The context was accepted; precedes any of its audio.
298        #[prost(message, tag = "3")]
299        Started(super::WebSocketStarted),
300        /// A chunk of encoded audio, in the format requested at `start`.
301        #[prost(bytes, tag = "4")]
302        Audio(::prost::alloc::vec::Vec<u8>),
303        /// Terminal: all audio for the context has been delivered.
304        #[prost(message, tag = "5")]
305        Done(super::WebSocketDone),
306        /// Terminal: the context was aborted by `cancel`.
307        #[prost(message, tag = "6")]
308        Cancelled(super::WebSocketCancelled),
309        /// Terminal for the context it names. Errors with an empty `context_id`
310        /// are connection-scoped and leave open contexts running; the server
311        /// closes the connection only when the failure is unrecoverable
312        /// (undecodable frames, failed authentication).
313        #[prost(message, tag = "7")]
314        Error(super::WebSocketError),
315    }
316}
317#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
318pub struct WebSocketReady {
319    /// Protocol version. Currently 1.
320    #[prost(uint32, tag = "1")]
321    pub protocol: u32,
322    /// Supported BCP-47 language tags (mirrors GetSupportedLanguages).
323    #[prost(string, repeated, tag = "2")]
324    pub languages: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
325    #[prost(string, optional, tag = "3")]
326    pub default_language: ::core::option::Option<::prost::alloc::string::String>,
327}
328#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
329pub struct WebSocketStarted {
330    /// Engine request id for this context; correlates with engine logs and
331    /// matches the `x-request-id` gRPC/HTTP metadata.
332    #[prost(string, tag = "1")]
333    pub request_id: ::prost::alloc::string::String,
334}
335#[derive(Clone, PartialEq, ::prost::Message)]
336pub struct WebSocketDone {
337    /// Present when `start.timestamps.enable` was set.
338    #[prost(message, optional, tag = "1")]
339    pub timestamps: ::core::option::Option<Timestamps>,
340}
341#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
342pub struct WebSocketCancelled {}
343#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
344pub struct WebSocketError {
345    /// Stable machine-readable kind; same values as the HTTP error body
346    /// (e.g. "invalid_input", "unauthenticated", "unavailable", "internal",
347    /// "unimplemented").
348    #[prost(string, tag = "1")]
349    pub kind: ::prost::alloc::string::String,
350    /// Human-readable description.
351    #[prost(string, tag = "2")]
352    pub message: ::prost::alloc::string::String,
353    /// Engine request id, when the error occurred inside a synthesis request.
354    #[prost(string, optional, tag = "3")]
355    pub request_id: ::core::option::Option<::prost::alloc::string::String>,
356}
357#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
358#[repr(i32)]
359pub enum SplitStrategy {
360    Unspecified = 0,
361    Sentence = 1,
362    None = 2,
363    /// Accumulates streamed sub-sentential text tokens into complete sentences
364    /// before synthesis. Only valid for streaming requests
365    /// (SynthesizeStreaming or the WebSocket API); a unary Synthesize request
366    /// that asks for it is rejected.
367    AccumulateSentence = 3,
368}
369impl SplitStrategy {
370    /// String value of the enum field names used in the ProtoBuf definition.
371    ///
372    /// The values are not transformed in any way and thus are considered stable
373    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
374    pub fn as_str_name(&self) -> &'static str {
375        match self {
376            Self::Unspecified => "SPLIT_STRATEGY_UNSPECIFIED",
377            Self::Sentence => "SPLIT_STRATEGY_SENTENCE",
378            Self::None => "SPLIT_STRATEGY_NONE",
379            Self::AccumulateSentence => "SPLIT_STRATEGY_ACCUMULATE_SENTENCE",
380        }
381    }
382    /// Creates an enum from field names used in the ProtoBuf definition.
383    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
384        match value {
385            "SPLIT_STRATEGY_UNSPECIFIED" => Some(Self::Unspecified),
386            "SPLIT_STRATEGY_SENTENCE" => Some(Self::Sentence),
387            "SPLIT_STRATEGY_NONE" => Some(Self::None),
388            "SPLIT_STRATEGY_ACCUMULATE_SENTENCE" => Some(Self::AccumulateSentence),
389            _ => None,
390        }
391    }
392}
393/// Generated client implementations.
394#[cfg(feature = "grpc")]
395pub mod text_to_speech_client {
396    #![allow(
397        unused_variables,
398        dead_code,
399        missing_docs,
400        clippy::wildcard_imports,
401        clippy::let_unit_value,
402    )]
403    use tonic::codegen::*;
404    use tonic::codegen::http::Uri;
405    #[derive(Debug, Clone)]
406    pub struct TextToSpeechClient<T> {
407        inner: tonic::client::Grpc<T>,
408    }
409    impl TextToSpeechClient<tonic::transport::Channel> {
410        /// Attempt to create a new client by connecting to a given endpoint.
411        pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
412        where
413            D: TryInto<tonic::transport::Endpoint>,
414            D::Error: Into<StdError>,
415        {
416            let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
417            Ok(Self::new(conn))
418        }
419    }
420    impl<T> TextToSpeechClient<T>
421    where
422        T: tonic::client::GrpcService<tonic::body::Body>,
423        T::Error: Into<StdError>,
424        T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
425        <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
426    {
427        pub fn new(inner: T) -> Self {
428            let inner = tonic::client::Grpc::new(inner);
429            Self { inner }
430        }
431        pub fn with_origin(inner: T, origin: Uri) -> Self {
432            let inner = tonic::client::Grpc::with_origin(inner, origin);
433            Self { inner }
434        }
435        pub fn with_interceptor<F>(
436            inner: T,
437            interceptor: F,
438        ) -> TextToSpeechClient<InterceptedService<T, F>>
439        where
440            F: tonic::service::Interceptor,
441            T::ResponseBody: Default,
442            T: tonic::codegen::Service<
443                http::Request<tonic::body::Body>,
444                Response = http::Response<
445                    <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
446                >,
447            >,
448            <T as tonic::codegen::Service<
449                http::Request<tonic::body::Body>,
450            >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
451        {
452            TextToSpeechClient::new(InterceptedService::new(inner, interceptor))
453        }
454        /// Compress requests with the given encoding.
455        ///
456        /// This requires the server to support it otherwise it might respond with an
457        /// error.
458        #[must_use]
459        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
460            self.inner = self.inner.send_compressed(encoding);
461            self
462        }
463        /// Enable decompressing responses.
464        #[must_use]
465        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
466            self.inner = self.inner.accept_compressed(encoding);
467            self
468        }
469        /// Limits the maximum size of a decoded message.
470        ///
471        /// Default: `4MB`
472        #[must_use]
473        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
474            self.inner = self.inner.max_decoding_message_size(limit);
475            self
476        }
477        /// Limits the maximum size of an encoded message.
478        ///
479        /// Default: `usize::MAX`
480        #[must_use]
481        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
482            self.inner = self.inner.max_encoding_message_size(limit);
483            self
484        }
485        pub async fn synthesize(
486            &mut self,
487            request: impl tonic::IntoRequest<super::SynthesisRequest>,
488        ) -> std::result::Result<
489            tonic::Response<tonic::codec::Streaming<super::SynthesisResponseStream>>,
490            tonic::Status,
491        > {
492            self.inner
493                .ready()
494                .await
495                .map_err(|e| {
496                    tonic::Status::unknown(
497                        format!("Service was not ready: {}", e.into()),
498                    )
499                })?;
500            let codec = tonic_prost::ProstCodec::default();
501            let path = http::uri::PathAndQuery::from_static(
502                "/rime.TextToSpeech/Synthesize",
503            );
504            let mut req = request.into_request();
505            req.extensions_mut()
506                .insert(GrpcMethod::new("rime.TextToSpeech", "Synthesize"));
507            self.inner.server_streaming(req, path, codec).await
508        }
509        /// Streaming text input: the client feeds text incrementally into a single
510        /// continuous synthesis. The FIRST client message MUST set `header` (all
511        /// synthesis params; its `text` field may carry the first chunk or be empty);
512        /// subsequent messages set `text_chunk`. End-of-input is signalled by the
513        /// client half-closing the request stream. Audio frames stream back as they
514        /// are produced.
515        pub async fn synthesize_streaming(
516            &mut self,
517            request: impl tonic::IntoStreamingRequest<
518                Message = super::StreamingSynthesisRequest,
519            >,
520        ) -> std::result::Result<
521            tonic::Response<tonic::codec::Streaming<super::SynthesisResponseStream>>,
522            tonic::Status,
523        > {
524            self.inner
525                .ready()
526                .await
527                .map_err(|e| {
528                    tonic::Status::unknown(
529                        format!("Service was not ready: {}", e.into()),
530                    )
531                })?;
532            let codec = tonic_prost::ProstCodec::default();
533            let path = http::uri::PathAndQuery::from_static(
534                "/rime.TextToSpeech/SynthesizeStreaming",
535            );
536            let mut req = request.into_streaming_request();
537            req.extensions_mut()
538                .insert(GrpcMethod::new("rime.TextToSpeech", "SynthesizeStreaming"));
539            self.inner.streaming(req, path, codec).await
540        }
541        pub async fn normalize_text(
542            &mut self,
543            request: impl tonic::IntoRequest<super::NormalizeTextRequest>,
544        ) -> std::result::Result<
545            tonic::Response<super::NormalizeTextResponse>,
546            tonic::Status,
547        > {
548            self.inner
549                .ready()
550                .await
551                .map_err(|e| {
552                    tonic::Status::unknown(
553                        format!("Service was not ready: {}", e.into()),
554                    )
555                })?;
556            let codec = tonic_prost::ProstCodec::default();
557            let path = http::uri::PathAndQuery::from_static(
558                "/rime.TextToSpeech/NormalizeText",
559            );
560            let mut req = request.into_request();
561            req.extensions_mut()
562                .insert(GrpcMethod::new("rime.TextToSpeech", "NormalizeText"));
563            self.inner.unary(req, path, codec).await
564        }
565        pub async fn get_supported_languages(
566            &mut self,
567            request: impl tonic::IntoRequest<super::GetSupportedLanguagesRequest>,
568        ) -> std::result::Result<
569            tonic::Response<super::GetSupportedLanguagesResponse>,
570            tonic::Status,
571        > {
572            self.inner
573                .ready()
574                .await
575                .map_err(|e| {
576                    tonic::Status::unknown(
577                        format!("Service was not ready: {}", e.into()),
578                    )
579                })?;
580            let codec = tonic_prost::ProstCodec::default();
581            let path = http::uri::PathAndQuery::from_static(
582                "/rime.TextToSpeech/GetSupportedLanguages",
583            );
584            let mut req = request.into_request();
585            req.extensions_mut()
586                .insert(GrpcMethod::new("rime.TextToSpeech", "GetSupportedLanguages"));
587            self.inner.unary(req, path, codec).await
588        }
589        pub async fn get_supported_speakers(
590            &mut self,
591            request: impl tonic::IntoRequest<super::GetSupportedSpeakersRequest>,
592        ) -> std::result::Result<
593            tonic::Response<super::GetSupportedSpeakersResponse>,
594            tonic::Status,
595        > {
596            self.inner
597                .ready()
598                .await
599                .map_err(|e| {
600                    tonic::Status::unknown(
601                        format!("Service was not ready: {}", e.into()),
602                    )
603                })?;
604            let codec = tonic_prost::ProstCodec::default();
605            let path = http::uri::PathAndQuery::from_static(
606                "/rime.TextToSpeech/GetSupportedSpeakers",
607            );
608            let mut req = request.into_request();
609            req.extensions_mut()
610                .insert(GrpcMethod::new("rime.TextToSpeech", "GetSupportedSpeakers"));
611            self.inner.unary(req, path, codec).await
612        }
613    }
614}
615/// Generated server implementations.
616#[cfg(feature = "grpc")]
617pub mod text_to_speech_server {
618    #![allow(
619        unused_variables,
620        dead_code,
621        missing_docs,
622        clippy::wildcard_imports,
623        clippy::let_unit_value,
624    )]
625    use tonic::codegen::*;
626    /// Generated trait containing gRPC methods that should be implemented for use with TextToSpeechServer.
627    #[async_trait]
628    pub trait TextToSpeech: std::marker::Send + std::marker::Sync + 'static {
629        /// Server streaming response type for the Synthesize method.
630        type SynthesizeStream: tonic::codegen::tokio_stream::Stream<
631                Item = std::result::Result<super::SynthesisResponseStream, tonic::Status>,
632            >
633            + std::marker::Send
634            + 'static;
635        async fn synthesize(
636            &self,
637            request: tonic::Request<super::SynthesisRequest>,
638        ) -> std::result::Result<tonic::Response<Self::SynthesizeStream>, tonic::Status>;
639        /// Server streaming response type for the SynthesizeStreaming method.
640        type SynthesizeStreamingStream: tonic::codegen::tokio_stream::Stream<
641                Item = std::result::Result<super::SynthesisResponseStream, tonic::Status>,
642            >
643            + std::marker::Send
644            + 'static;
645        /// Streaming text input: the client feeds text incrementally into a single
646        /// continuous synthesis. The FIRST client message MUST set `header` (all
647        /// synthesis params; its `text` field may carry the first chunk or be empty);
648        /// subsequent messages set `text_chunk`. End-of-input is signalled by the
649        /// client half-closing the request stream. Audio frames stream back as they
650        /// are produced.
651        async fn synthesize_streaming(
652            &self,
653            request: tonic::Request<tonic::Streaming<super::StreamingSynthesisRequest>>,
654        ) -> std::result::Result<
655            tonic::Response<Self::SynthesizeStreamingStream>,
656            tonic::Status,
657        >;
658        async fn normalize_text(
659            &self,
660            request: tonic::Request<super::NormalizeTextRequest>,
661        ) -> std::result::Result<
662            tonic::Response<super::NormalizeTextResponse>,
663            tonic::Status,
664        >;
665        async fn get_supported_languages(
666            &self,
667            request: tonic::Request<super::GetSupportedLanguagesRequest>,
668        ) -> std::result::Result<
669            tonic::Response<super::GetSupportedLanguagesResponse>,
670            tonic::Status,
671        >;
672        async fn get_supported_speakers(
673            &self,
674            request: tonic::Request<super::GetSupportedSpeakersRequest>,
675        ) -> std::result::Result<
676            tonic::Response<super::GetSupportedSpeakersResponse>,
677            tonic::Status,
678        >;
679    }
680    #[derive(Debug)]
681    pub struct TextToSpeechServer<T> {
682        inner: Arc<T>,
683        accept_compression_encodings: EnabledCompressionEncodings,
684        send_compression_encodings: EnabledCompressionEncodings,
685        max_decoding_message_size: Option<usize>,
686        max_encoding_message_size: Option<usize>,
687    }
688    impl<T> TextToSpeechServer<T> {
689        pub fn new(inner: T) -> Self {
690            Self::from_arc(Arc::new(inner))
691        }
692        pub fn from_arc(inner: Arc<T>) -> Self {
693            Self {
694                inner,
695                accept_compression_encodings: Default::default(),
696                send_compression_encodings: Default::default(),
697                max_decoding_message_size: None,
698                max_encoding_message_size: None,
699            }
700        }
701        pub fn with_interceptor<F>(
702            inner: T,
703            interceptor: F,
704        ) -> InterceptedService<Self, F>
705        where
706            F: tonic::service::Interceptor,
707        {
708            InterceptedService::new(Self::new(inner), interceptor)
709        }
710        /// Enable decompressing requests with the given encoding.
711        #[must_use]
712        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
713            self.accept_compression_encodings.enable(encoding);
714            self
715        }
716        /// Compress responses with the given encoding, if the client supports it.
717        #[must_use]
718        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
719            self.send_compression_encodings.enable(encoding);
720            self
721        }
722        /// Limits the maximum size of a decoded message.
723        ///
724        /// Default: `4MB`
725        #[must_use]
726        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
727            self.max_decoding_message_size = Some(limit);
728            self
729        }
730        /// Limits the maximum size of an encoded message.
731        ///
732        /// Default: `usize::MAX`
733        #[must_use]
734        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
735            self.max_encoding_message_size = Some(limit);
736            self
737        }
738    }
739    impl<T, B> tonic::codegen::Service<http::Request<B>> for TextToSpeechServer<T>
740    where
741        T: TextToSpeech,
742        B: Body + std::marker::Send + 'static,
743        B::Error: Into<StdError> + std::marker::Send + 'static,
744    {
745        type Response = http::Response<tonic::body::Body>;
746        type Error = std::convert::Infallible;
747        type Future = BoxFuture<Self::Response, Self::Error>;
748        fn poll_ready(
749            &mut self,
750            _cx: &mut Context<'_>,
751        ) -> Poll<std::result::Result<(), Self::Error>> {
752            Poll::Ready(Ok(()))
753        }
754        fn call(&mut self, req: http::Request<B>) -> Self::Future {
755            match req.uri().path() {
756                "/rime.TextToSpeech/Synthesize" => {
757                    #[allow(non_camel_case_types)]
758                    struct SynthesizeSvc<T: TextToSpeech>(pub Arc<T>);
759                    impl<
760                        T: TextToSpeech,
761                    > tonic::server::ServerStreamingService<super::SynthesisRequest>
762                    for SynthesizeSvc<T> {
763                        type Response = super::SynthesisResponseStream;
764                        type ResponseStream = T::SynthesizeStream;
765                        type Future = BoxFuture<
766                            tonic::Response<Self::ResponseStream>,
767                            tonic::Status,
768                        >;
769                        fn call(
770                            &mut self,
771                            request: tonic::Request<super::SynthesisRequest>,
772                        ) -> Self::Future {
773                            let inner = Arc::clone(&self.0);
774                            let fut = async move {
775                                <T as TextToSpeech>::synthesize(&inner, request).await
776                            };
777                            Box::pin(fut)
778                        }
779                    }
780                    let accept_compression_encodings = self.accept_compression_encodings;
781                    let send_compression_encodings = self.send_compression_encodings;
782                    let max_decoding_message_size = self.max_decoding_message_size;
783                    let max_encoding_message_size = self.max_encoding_message_size;
784                    let inner = self.inner.clone();
785                    let fut = async move {
786                        let method = SynthesizeSvc(inner);
787                        let codec = tonic_prost::ProstCodec::default();
788                        let mut grpc = tonic::server::Grpc::new(codec)
789                            .apply_compression_config(
790                                accept_compression_encodings,
791                                send_compression_encodings,
792                            )
793                            .apply_max_message_size_config(
794                                max_decoding_message_size,
795                                max_encoding_message_size,
796                            );
797                        let res = grpc.server_streaming(method, req).await;
798                        Ok(res)
799                    };
800                    Box::pin(fut)
801                }
802                "/rime.TextToSpeech/SynthesizeStreaming" => {
803                    #[allow(non_camel_case_types)]
804                    struct SynthesizeStreamingSvc<T: TextToSpeech>(pub Arc<T>);
805                    impl<
806                        T: TextToSpeech,
807                    > tonic::server::StreamingService<super::StreamingSynthesisRequest>
808                    for SynthesizeStreamingSvc<T> {
809                        type Response = super::SynthesisResponseStream;
810                        type ResponseStream = T::SynthesizeStreamingStream;
811                        type Future = BoxFuture<
812                            tonic::Response<Self::ResponseStream>,
813                            tonic::Status,
814                        >;
815                        fn call(
816                            &mut self,
817                            request: tonic::Request<
818                                tonic::Streaming<super::StreamingSynthesisRequest>,
819                            >,
820                        ) -> Self::Future {
821                            let inner = Arc::clone(&self.0);
822                            let fut = async move {
823                                <T as TextToSpeech>::synthesize_streaming(&inner, request)
824                                    .await
825                            };
826                            Box::pin(fut)
827                        }
828                    }
829                    let accept_compression_encodings = self.accept_compression_encodings;
830                    let send_compression_encodings = self.send_compression_encodings;
831                    let max_decoding_message_size = self.max_decoding_message_size;
832                    let max_encoding_message_size = self.max_encoding_message_size;
833                    let inner = self.inner.clone();
834                    let fut = async move {
835                        let method = SynthesizeStreamingSvc(inner);
836                        let codec = tonic_prost::ProstCodec::default();
837                        let mut grpc = tonic::server::Grpc::new(codec)
838                            .apply_compression_config(
839                                accept_compression_encodings,
840                                send_compression_encodings,
841                            )
842                            .apply_max_message_size_config(
843                                max_decoding_message_size,
844                                max_encoding_message_size,
845                            );
846                        let res = grpc.streaming(method, req).await;
847                        Ok(res)
848                    };
849                    Box::pin(fut)
850                }
851                "/rime.TextToSpeech/NormalizeText" => {
852                    #[allow(non_camel_case_types)]
853                    struct NormalizeTextSvc<T: TextToSpeech>(pub Arc<T>);
854                    impl<
855                        T: TextToSpeech,
856                    > tonic::server::UnaryService<super::NormalizeTextRequest>
857                    for NormalizeTextSvc<T> {
858                        type Response = super::NormalizeTextResponse;
859                        type Future = BoxFuture<
860                            tonic::Response<Self::Response>,
861                            tonic::Status,
862                        >;
863                        fn call(
864                            &mut self,
865                            request: tonic::Request<super::NormalizeTextRequest>,
866                        ) -> Self::Future {
867                            let inner = Arc::clone(&self.0);
868                            let fut = async move {
869                                <T as TextToSpeech>::normalize_text(&inner, request).await
870                            };
871                            Box::pin(fut)
872                        }
873                    }
874                    let accept_compression_encodings = self.accept_compression_encodings;
875                    let send_compression_encodings = self.send_compression_encodings;
876                    let max_decoding_message_size = self.max_decoding_message_size;
877                    let max_encoding_message_size = self.max_encoding_message_size;
878                    let inner = self.inner.clone();
879                    let fut = async move {
880                        let method = NormalizeTextSvc(inner);
881                        let codec = tonic_prost::ProstCodec::default();
882                        let mut grpc = tonic::server::Grpc::new(codec)
883                            .apply_compression_config(
884                                accept_compression_encodings,
885                                send_compression_encodings,
886                            )
887                            .apply_max_message_size_config(
888                                max_decoding_message_size,
889                                max_encoding_message_size,
890                            );
891                        let res = grpc.unary(method, req).await;
892                        Ok(res)
893                    };
894                    Box::pin(fut)
895                }
896                "/rime.TextToSpeech/GetSupportedLanguages" => {
897                    #[allow(non_camel_case_types)]
898                    struct GetSupportedLanguagesSvc<T: TextToSpeech>(pub Arc<T>);
899                    impl<
900                        T: TextToSpeech,
901                    > tonic::server::UnaryService<super::GetSupportedLanguagesRequest>
902                    for GetSupportedLanguagesSvc<T> {
903                        type Response = super::GetSupportedLanguagesResponse;
904                        type Future = BoxFuture<
905                            tonic::Response<Self::Response>,
906                            tonic::Status,
907                        >;
908                        fn call(
909                            &mut self,
910                            request: tonic::Request<super::GetSupportedLanguagesRequest>,
911                        ) -> Self::Future {
912                            let inner = Arc::clone(&self.0);
913                            let fut = async move {
914                                <T as TextToSpeech>::get_supported_languages(
915                                        &inner,
916                                        request,
917                                    )
918                                    .await
919                            };
920                            Box::pin(fut)
921                        }
922                    }
923                    let accept_compression_encodings = self.accept_compression_encodings;
924                    let send_compression_encodings = self.send_compression_encodings;
925                    let max_decoding_message_size = self.max_decoding_message_size;
926                    let max_encoding_message_size = self.max_encoding_message_size;
927                    let inner = self.inner.clone();
928                    let fut = async move {
929                        let method = GetSupportedLanguagesSvc(inner);
930                        let codec = tonic_prost::ProstCodec::default();
931                        let mut grpc = tonic::server::Grpc::new(codec)
932                            .apply_compression_config(
933                                accept_compression_encodings,
934                                send_compression_encodings,
935                            )
936                            .apply_max_message_size_config(
937                                max_decoding_message_size,
938                                max_encoding_message_size,
939                            );
940                        let res = grpc.unary(method, req).await;
941                        Ok(res)
942                    };
943                    Box::pin(fut)
944                }
945                "/rime.TextToSpeech/GetSupportedSpeakers" => {
946                    #[allow(non_camel_case_types)]
947                    struct GetSupportedSpeakersSvc<T: TextToSpeech>(pub Arc<T>);
948                    impl<
949                        T: TextToSpeech,
950                    > tonic::server::UnaryService<super::GetSupportedSpeakersRequest>
951                    for GetSupportedSpeakersSvc<T> {
952                        type Response = super::GetSupportedSpeakersResponse;
953                        type Future = BoxFuture<
954                            tonic::Response<Self::Response>,
955                            tonic::Status,
956                        >;
957                        fn call(
958                            &mut self,
959                            request: tonic::Request<super::GetSupportedSpeakersRequest>,
960                        ) -> Self::Future {
961                            let inner = Arc::clone(&self.0);
962                            let fut = async move {
963                                <T as TextToSpeech>::get_supported_speakers(&inner, request)
964                                    .await
965                            };
966                            Box::pin(fut)
967                        }
968                    }
969                    let accept_compression_encodings = self.accept_compression_encodings;
970                    let send_compression_encodings = self.send_compression_encodings;
971                    let max_decoding_message_size = self.max_decoding_message_size;
972                    let max_encoding_message_size = self.max_encoding_message_size;
973                    let inner = self.inner.clone();
974                    let fut = async move {
975                        let method = GetSupportedSpeakersSvc(inner);
976                        let codec = tonic_prost::ProstCodec::default();
977                        let mut grpc = tonic::server::Grpc::new(codec)
978                            .apply_compression_config(
979                                accept_compression_encodings,
980                                send_compression_encodings,
981                            )
982                            .apply_max_message_size_config(
983                                max_decoding_message_size,
984                                max_encoding_message_size,
985                            );
986                        let res = grpc.unary(method, req).await;
987                        Ok(res)
988                    };
989                    Box::pin(fut)
990                }
991                _ => {
992                    Box::pin(async move {
993                        let mut response = http::Response::new(
994                            tonic::body::Body::default(),
995                        );
996                        let headers = response.headers_mut();
997                        headers
998                            .insert(
999                                tonic::Status::GRPC_STATUS,
1000                                (tonic::Code::Unimplemented as i32).into(),
1001                            );
1002                        headers
1003                            .insert(
1004                                http::header::CONTENT_TYPE,
1005                                tonic::metadata::GRPC_CONTENT_TYPE,
1006                            );
1007                        Ok(response)
1008                    })
1009                }
1010            }
1011        }
1012    }
1013    impl<T> Clone for TextToSpeechServer<T> {
1014        fn clone(&self) -> Self {
1015            let inner = self.inner.clone();
1016            Self {
1017                inner,
1018                accept_compression_encodings: self.accept_compression_encodings,
1019                send_compression_encodings: self.send_compression_encodings,
1020                max_decoding_message_size: self.max_decoding_message_size,
1021                max_encoding_message_size: self.max_encoding_message_size,
1022            }
1023        }
1024    }
1025    /// Generated gRPC service name
1026    pub const SERVICE_NAME: &str = "rime.TextToSpeech";
1027    impl<T> tonic::server::NamedService for TextToSpeechServer<T> {
1028        const NAME: &'static str = SERVICE_NAME;
1029    }
1030}
1031#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
1032pub struct TranscriptionOptions {
1033    /// Required BCP-47 tag of the spoken language, resolved against the packaged
1034    /// catalog (`en` or `es`). An omitted tag or `und` is rejected with
1035    /// INVALID_ARGUMENT.
1036    #[prost(string, optional, tag = "1")]
1037    pub language: ::core::option::Option<::prost::alloc::string::String>,
1038    #[prost(enumeration = "TranscriptionMode", tag = "2")]
1039    pub mode: i32,
1040    /// Recognition terms, for example \["Mitchell Gourley", "Super-G", "USOC"\].
1041    /// An empty list adds no bias; the service rejects empty or whitespace-only
1042    /// terms. Order and term text are preserved, with ", " inserted between
1043    /// terms before composition into the packaged mode prompt. The packaged
1044    /// model's caller-context budget counts UTF-8 bytes including separators;
1045    /// the composed prompt keeps the mode prompt intact.
1046    /// Terms softly bias recognition without forcing a match; per-word weights
1047    /// are not supported.
1048    #[prost(string, repeated, tag = "3")]
1049    pub context_terms: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
1050}
1051#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
1052pub struct ResolvedLanguage {
1053    /// Canonical BCP-47 tag drawn from the packaged model catalog.
1054    #[prost(string, tag = "1")]
1055    pub tag: ::prost::alloc::string::String,
1056    #[prost(enumeration = "LanguageSource", tag = "2")]
1057    pub source: i32,
1058}
1059#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
1060pub struct TranscriptionRequest {
1061    /// A complete WAV file, including its RIFF/WAVE header, bounded to 16 MiB.
1062    /// PCM16 little-endian mono 16 kHz is the qualified input format. The
1063    /// packaged decoder may accept other WAV encodings/rates; those extensions
1064    /// are not a portable interface guarantee. Headerless PCM is not WAV.
1065    #[prost(bytes = "vec", tag = "1")]
1066    pub audio: ::prost::alloc::vec::Vec<u8>,
1067    /// Required: `language` must select the spoken language.
1068    #[prost(message, optional, tag = "2")]
1069    pub options: ::core::option::Option<TranscriptionOptions>,
1070}
1071#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
1072pub struct TranscriptionResponse {
1073    #[prost(string, tag = "1")]
1074    pub text: ::prost::alloc::string::String,
1075    /// The canonical catalog language the caller selected.
1076    #[prost(message, optional, tag = "2")]
1077    pub language: ::core::option::Option<ResolvedLanguage>,
1078}
1079/// Streaming input is always headerless signed PCM16 little-endian mono
1080/// 16 kHz; the format is not configurable.
1081#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
1082pub struct StreamingConfig {
1083    /// Under either output contract, `language` is a required BCP-47 tag (an
1084    /// omitted tag or `und` is rejected) and `mode` selects the written or
1085    /// verbatim prompt.
1086    #[prost(string, optional, tag = "3")]
1087    pub language: ::core::option::Option<::prost::alloc::string::String>,
1088    #[prost(enumeration = "TranscriptionMode", tag = "4")]
1089    pub mode: i32,
1090    /// Explicitly selects the output contract. The service confirms the
1091    /// selection before accepting audio; an unrecognized value is rejected
1092    /// rather than silently downgraded.
1093    #[prost(enumeration = "StreamingOutputContract", tag = "5")]
1094    pub output_contract: i32,
1095    /// Recognition terms under either output contract. Same validation, budgets
1096    /// and composition as TranscriptionOptions.context_terms; an empty list adds
1097    /// no bias.
1098    #[prost(string, repeated, tag = "6")]
1099    pub context_terms: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
1100}
1101#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
1102pub struct StreamingTranscriptionRequest {
1103    #[prost(oneof = "streaming_transcription_request::Payload", tags = "1, 2")]
1104    pub payload: ::core::option::Option<streaming_transcription_request::Payload>,
1105}
1106/// Nested message and enum types in `StreamingTranscriptionRequest`.
1107pub mod streaming_transcription_request {
1108    #[derive(Clone, PartialEq, Eq, Hash, ::prost::Oneof)]
1109    pub enum Payload {
1110        /// Required exactly once as the first request.
1111        #[prost(message, tag = "1")]
1112        Config(super::StreamingConfig),
1113        /// PCM16 bytes. Each message is bounded to 64 KiB and the utterance to
1114        /// 16 MiB. An odd byte count is invalid.
1115        #[prost(bytes, tag = "2")]
1116        Audio(::prost::alloc::vec::Vec<u8>),
1117    }
1118}
1119#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
1120pub struct StreamingTranscriptionResponse {
1121    #[prost(oneof = "streaming_transcription_response::Payload", tags = "1, 2, 3, 4")]
1122    pub payload: ::core::option::Option<streaming_transcription_response::Payload>,
1123}
1124/// Nested message and enum types in `StreamingTranscriptionResponse`.
1125pub mod streaming_transcription_response {
1126    #[derive(Clone, PartialEq, Eq, Hash, ::prost::Oneof)]
1127    pub enum Payload {
1128        /// An append-only transcript fragment under the append-fragment contract.
1129        /// Concatenate deltas in arrival order, including newline separators
1130        /// between transcription windows; they are not replacement hypotheses.
1131        #[prost(message, tag = "1")]
1132        Delta(super::TranscriptionDelta),
1133        /// Exactly one final transcript for a successfully completed utterance.
1134        /// Under the append-fragment contract its text equals the concatenation of
1135        /// all preceding delta fragments; under
1136        /// STREAMING_OUTPUT_CONTRACT_REVISED_HYPOTHESES it equals the last
1137        /// hypothesis. It may be empty when the input contains no recognized
1138        /// speech.
1139        #[prost(message, tag = "2")]
1140        Done(super::TranscriptionDone),
1141        /// Confirms the selected output contract before any audio-derived
1142        /// response. Every accepted configuration selects
1143        /// STREAMING_OUTPUT_CONTRACT_APPEND_FRAGMENTS or
1144        /// STREAMING_OUTPUT_CONTRACT_REVISED_HYPOTHESES;
1145        /// STREAMING_OUTPUT_CONTRACT_UNSPECIFIED is rejected as invalid input.
1146        #[prost(message, tag = "3")]
1147        Accepted(super::StreamingAccepted),
1148        /// The latest full transcript hypothesis under
1149        /// STREAMING_OUTPUT_CONTRACT_REVISED_HYPOTHESES. Each hypothesis replaces
1150        /// the previous one entirely.
1151        #[prost(message, tag = "4")]
1152        Hypothesis(super::TranscriptionHypothesis),
1153    }
1154}
1155#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
1156pub struct StreamingAccepted {
1157    #[prost(enumeration = "StreamingOutputContract", tag = "1")]
1158    pub output_contract: i32,
1159    /// Confirms the selected language.
1160    #[prost(message, optional, tag = "2")]
1161    pub language: ::core::option::Option<ResolvedLanguage>,
1162}
1163#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
1164pub struct TranscriptionDelta {
1165    #[prost(string, tag = "1")]
1166    pub text: ::prost::alloc::string::String,
1167}
1168/// A full-hypothesis partial. `text` is the complete current transcript, not a
1169/// delta; a later hypothesis with a higher revision replaces it.
1170#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
1171pub struct TranscriptionHypothesis {
1172    #[prost(string, tag = "1")]
1173    pub text: ::prost::alloc::string::String,
1174    /// Monotonically increasing within a session, starting at 1.
1175    #[prost(uint64, tag = "2")]
1176    pub revision: u64,
1177}
1178#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
1179pub struct TranscriptionDone {
1180    #[prost(string, tag = "1")]
1181    pub text: ::prost::alloc::string::String,
1182    /// See TranscriptionResponse.language. Reported under either output
1183    /// contract.
1184    #[prost(message, optional, tag = "2")]
1185    pub language: ::core::option::Option<ResolvedLanguage>,
1186    /// The revision of the final hypothesis under
1187    /// STREAMING_OUTPUT_CONTRACT_REVISED_HYPOTHESES; zero under the
1188    /// append-fragment contract.
1189    #[prost(uint64, tag = "3")]
1190    pub revision: u64,
1191}
1192#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
1193pub struct SpeechWebSocketRequest {
1194    #[prost(oneof = "speech_web_socket_request::Payload", tags = "1, 2, 3, 4")]
1195    pub payload: ::core::option::Option<speech_web_socket_request::Payload>,
1196}
1197/// Nested message and enum types in `SpeechWebSocketRequest`.
1198pub mod speech_web_socket_request {
1199    #[derive(Clone, PartialEq, Eq, Hash, ::prost::Oneof)]
1200    pub enum Payload {
1201        #[prost(message, tag = "1")]
1202        Start(super::StreamingConfig),
1203        #[prost(bytes, tag = "2")]
1204        Audio(::prost::alloc::vec::Vec<u8>),
1205        #[prost(message, tag = "3")]
1206        End(super::SpeechWebSocketEnd),
1207        #[prost(message, tag = "4")]
1208        Cancel(super::SpeechWebSocketCancel),
1209    }
1210}
1211#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
1212pub struct SpeechWebSocketEnd {}
1213#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
1214pub struct SpeechWebSocketCancel {}
1215#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
1216pub struct SpeechWebSocketResponse {
1217    #[prost(oneof = "speech_web_socket_response::Payload", tags = "1, 2, 3, 4, 5, 6")]
1218    pub payload: ::core::option::Option<speech_web_socket_response::Payload>,
1219}
1220/// Nested message and enum types in `SpeechWebSocketResponse`.
1221pub mod speech_web_socket_response {
1222    #[derive(Clone, PartialEq, Eq, Hash, ::prost::Oneof)]
1223    pub enum Payload {
1224        #[prost(message, tag = "1")]
1225        Started(super::SpeechWebSocketStarted),
1226        #[prost(message, tag = "2")]
1227        Delta(super::TranscriptionDelta),
1228        #[prost(message, tag = "3")]
1229        Done(super::TranscriptionDone),
1230        #[prost(message, tag = "4")]
1231        Error(super::SpeechWebSocketError),
1232        #[prost(message, tag = "5")]
1233        Cancelled(super::SpeechWebSocketCancelled),
1234        /// Full-hypothesis partial under
1235        /// STREAMING_OUTPUT_CONTRACT_REVISED_HYPOTHESES; see
1236        /// TranscriptionHypothesis.
1237        #[prost(message, tag = "6")]
1238        Hypothesis(super::TranscriptionHypothesis),
1239    }
1240}
1241#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
1242pub struct SpeechWebSocketStarted {
1243    #[prost(string, tag = "1")]
1244    pub request_id: ::prost::alloc::string::String,
1245    /// Confirms STREAMING_OUTPUT_CONTRACT_APPEND_FRAGMENTS or
1246    /// STREAMING_OUTPUT_CONTRACT_REVISED_HYPOTHESES before any audio-derived
1247    /// response. Present for every accepted configuration.
1248    #[prost(message, optional, tag = "2")]
1249    pub accepted: ::core::option::Option<StreamingAccepted>,
1250}
1251#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
1252pub struct SpeechWebSocketError {
1253    /// Stable public category such as invalid_input, resource_exhausted,
1254    /// unavailable, timeout, cancelled, or internal.
1255    #[prost(string, tag = "1")]
1256    pub kind: ::prost::alloc::string::String,
1257    /// Human-readable diagnostic; clients branch on `kind`, not this text.
1258    #[prost(string, tag = "2")]
1259    pub message: ::prost::alloc::string::String,
1260    #[prost(string, optional, tag = "3")]
1261    pub request_id: ::core::option::Option<::prost::alloc::string::String>,
1262}
1263/// Acknowledges an explicit `cancel`. Closing the connection instead also
1264/// cancels its associated backend work, but cannot carry this acknowledgement.
1265#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
1266pub struct SpeechWebSocketCancelled {}
1267/// Output formatting intent. The packaged model prompt describes the intent;
1268/// it steers the model rather than hard-guaranteeing token-level behavior.
1269#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
1270#[repr(i32)]
1271pub enum TranscriptionMode {
1272    /// Defaults to TRANSCRIPTION_MODE_WRITTEN.
1273    Unspecified = 0,
1274    /// Standard written formatting: numerals as digits, codes compact.
1275    /// "flight two four seven" is intended to come back as "flight 247".
1276    Written = 1,
1277    /// Verbatim rendering: keep every filler, repetition, and false start;
1278    /// numbers as spoken words. "uh flight two four seven" is intended to come
1279    /// back as "uh flight two four seven".
1280    Verbatim = 2,
1281}
1282impl TranscriptionMode {
1283    /// String value of the enum field names used in the ProtoBuf definition.
1284    ///
1285    /// The values are not transformed in any way and thus are considered stable
1286    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
1287    pub fn as_str_name(&self) -> &'static str {
1288        match self {
1289            Self::Unspecified => "TRANSCRIPTION_MODE_UNSPECIFIED",
1290            Self::Written => "TRANSCRIPTION_MODE_WRITTEN",
1291            Self::Verbatim => "TRANSCRIPTION_MODE_VERBATIM",
1292        }
1293    }
1294    /// Creates an enum from field names used in the ProtoBuf definition.
1295    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
1296        match value {
1297            "TRANSCRIPTION_MODE_UNSPECIFIED" => Some(Self::Unspecified),
1298            "TRANSCRIPTION_MODE_WRITTEN" => Some(Self::Written),
1299            "TRANSCRIPTION_MODE_VERBATIM" => Some(Self::Verbatim),
1300            _ => None,
1301        }
1302    }
1303}
1304/// How the resolved language was chosen.
1305#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
1306#[repr(i32)]
1307pub enum LanguageSource {
1308    /// The service could not resolve a catalog language for this result. Never
1309    /// a silent substitute for LANGUAGE_SOURCE_SELECTED or
1310    /// LANGUAGE_SOURCE_DETECTED.
1311    Unspecified = 0,
1312    /// The caller supplied the language and the service confirmed it against
1313    /// the packaged model catalog.
1314    Selected = 1,
1315    /// The model detected the served catalog language. Not produced while every
1316    /// request must select its language.
1317    Detected = 2,
1318}
1319impl LanguageSource {
1320    /// String value of the enum field names used in the ProtoBuf definition.
1321    ///
1322    /// The values are not transformed in any way and thus are considered stable
1323    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
1324    pub fn as_str_name(&self) -> &'static str {
1325        match self {
1326            Self::Unspecified => "LANGUAGE_SOURCE_UNSPECIFIED",
1327            Self::Selected => "LANGUAGE_SOURCE_SELECTED",
1328            Self::Detected => "LANGUAGE_SOURCE_DETECTED",
1329        }
1330    }
1331    /// Creates an enum from field names used in the ProtoBuf definition.
1332    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
1333        match value {
1334            "LANGUAGE_SOURCE_UNSPECIFIED" => Some(Self::Unspecified),
1335            "LANGUAGE_SOURCE_SELECTED" => Some(Self::Selected),
1336            "LANGUAGE_SOURCE_DETECTED" => Some(Self::Detected),
1337            _ => None,
1338        }
1339    }
1340}
1341/// Which streaming output contract the session uses.
1342#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
1343#[repr(i32)]
1344pub enum StreamingOutputContract {
1345    /// Invalid for a request: callers must explicitly select an output contract.
1346    Unspecified = 0,
1347    /// Responses are append-only `delta` fragments: each five-second window of
1348    /// audio is transcribed once, on its own, so a fragment is never revised.
1349    /// Concatenate them in arrival order (including newline separators between
1350    /// transcription windows) to form the transcript. The final `done` text
1351    /// equals that concatenation.
1352    AppendFragments = 1,
1353    /// Responses are full replacing `hypothesis` transcripts: each hypothesis
1354    /// carries the complete current transcript and a monotonically increasing
1355    /// revision, and entirely replaces the previous one. The final `done` text
1356    /// equals the last hypothesis and carries its revision; an utterance with
1357    /// no recognized speech may emit no hypothesis and finishes with an empty
1358    /// final at revision zero.
1359    RevisedHypotheses = 2,
1360}
1361impl StreamingOutputContract {
1362    /// String value of the enum field names used in the ProtoBuf definition.
1363    ///
1364    /// The values are not transformed in any way and thus are considered stable
1365    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
1366    pub fn as_str_name(&self) -> &'static str {
1367        match self {
1368            Self::Unspecified => "STREAMING_OUTPUT_CONTRACT_UNSPECIFIED",
1369            Self::AppendFragments => "STREAMING_OUTPUT_CONTRACT_APPEND_FRAGMENTS",
1370            Self::RevisedHypotheses => "STREAMING_OUTPUT_CONTRACT_REVISED_HYPOTHESES",
1371        }
1372    }
1373    /// Creates an enum from field names used in the ProtoBuf definition.
1374    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
1375        match value {
1376            "STREAMING_OUTPUT_CONTRACT_UNSPECIFIED" => Some(Self::Unspecified),
1377            "STREAMING_OUTPUT_CONTRACT_APPEND_FRAGMENTS" => Some(Self::AppendFragments),
1378            "STREAMING_OUTPUT_CONTRACT_REVISED_HYPOTHESES" => {
1379                Some(Self::RevisedHypotheses)
1380            }
1381            _ => None,
1382        }
1383    }
1384}
1385/// Generated client implementations.
1386#[cfg(feature = "grpc")]
1387pub mod speech_to_text_client {
1388    #![allow(
1389        unused_variables,
1390        dead_code,
1391        missing_docs,
1392        clippy::wildcard_imports,
1393        clippy::let_unit_value,
1394    )]
1395    use tonic::codegen::*;
1396    use tonic::codegen::http::Uri;
1397    /// Whole-utterance and realtime speech recognition for Cassowary. Cassowary
1398    /// adapts this public contract to the native vLLM chat API; vLLM owns model
1399    /// loading, inference, and GPU scheduling.
1400    #[derive(Debug, Clone)]
1401    pub struct SpeechToTextClient<T> {
1402        inner: tonic::client::Grpc<T>,
1403    }
1404    impl SpeechToTextClient<tonic::transport::Channel> {
1405        /// Attempt to create a new client by connecting to a given endpoint.
1406        pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
1407        where
1408            D: TryInto<tonic::transport::Endpoint>,
1409            D::Error: Into<StdError>,
1410        {
1411            let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
1412            Ok(Self::new(conn))
1413        }
1414    }
1415    impl<T> SpeechToTextClient<T>
1416    where
1417        T: tonic::client::GrpcService<tonic::body::Body>,
1418        T::Error: Into<StdError>,
1419        T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
1420        <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
1421    {
1422        pub fn new(inner: T) -> Self {
1423            let inner = tonic::client::Grpc::new(inner);
1424            Self { inner }
1425        }
1426        pub fn with_origin(inner: T, origin: Uri) -> Self {
1427            let inner = tonic::client::Grpc::with_origin(inner, origin);
1428            Self { inner }
1429        }
1430        pub fn with_interceptor<F>(
1431            inner: T,
1432            interceptor: F,
1433        ) -> SpeechToTextClient<InterceptedService<T, F>>
1434        where
1435            F: tonic::service::Interceptor,
1436            T::ResponseBody: Default,
1437            T: tonic::codegen::Service<
1438                http::Request<tonic::body::Body>,
1439                Response = http::Response<
1440                    <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
1441                >,
1442            >,
1443            <T as tonic::codegen::Service<
1444                http::Request<tonic::body::Body>,
1445            >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
1446        {
1447            SpeechToTextClient::new(InterceptedService::new(inner, interceptor))
1448        }
1449        /// Compress requests with the given encoding.
1450        ///
1451        /// This requires the server to support it otherwise it might respond with an
1452        /// error.
1453        #[must_use]
1454        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
1455            self.inner = self.inner.send_compressed(encoding);
1456            self
1457        }
1458        /// Enable decompressing responses.
1459        #[must_use]
1460        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
1461            self.inner = self.inner.accept_compressed(encoding);
1462            self
1463        }
1464        /// Limits the maximum size of a decoded message.
1465        ///
1466        /// Default: `4MB`
1467        #[must_use]
1468        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
1469            self.inner = self.inner.max_decoding_message_size(limit);
1470            self
1471        }
1472        /// Limits the maximum size of an encoded message.
1473        ///
1474        /// Default: `usize::MAX`
1475        #[must_use]
1476        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
1477            self.inner = self.inner.max_encoding_message_size(limit);
1478            self
1479        }
1480        /// Transcribes one complete WAV payload. Language and formatting mode are
1481        /// available for the whole-utterance model path.
1482        pub async fn transcribe(
1483            &mut self,
1484            request: impl tonic::IntoRequest<super::TranscriptionRequest>,
1485        ) -> std::result::Result<
1486            tonic::Response<super::TranscriptionResponse>,
1487            tonic::Status,
1488        > {
1489            self.inner
1490                .ready()
1491                .await
1492                .map_err(|e| {
1493                    tonic::Status::unknown(
1494                        format!("Service was not ready: {}", e.into()),
1495                    )
1496                })?;
1497            let codec = tonic_prost::ProstCodec::default();
1498            let path = http::uri::PathAndQuery::from_static(
1499                "/rime.SpeechToText/Transcribe",
1500            );
1501            let mut req = request.into_request();
1502            req.extensions_mut()
1503                .insert(GrpcMethod::new("rime.SpeechToText", "Transcribe"));
1504            self.inner.unary(req, path, codec).await
1505        }
1506        /// Transcribes exactly one realtime PCM16 mono 16 kHz utterance per client
1507        /// stream. The first request must contain `config`; following requests contain
1508        /// audio. Client half-close commits the utterance and produces one final `done`
1509        /// response. Dropping either side of the RPC cancels the associated backend
1510        /// work.
1511        pub async fn transcribe_streaming(
1512            &mut self,
1513            request: impl tonic::IntoStreamingRequest<
1514                Message = super::StreamingTranscriptionRequest,
1515            >,
1516        ) -> std::result::Result<
1517            tonic::Response<
1518                tonic::codec::Streaming<super::StreamingTranscriptionResponse>,
1519            >,
1520            tonic::Status,
1521        > {
1522            self.inner
1523                .ready()
1524                .await
1525                .map_err(|e| {
1526                    tonic::Status::unknown(
1527                        format!("Service was not ready: {}", e.into()),
1528                    )
1529                })?;
1530            let codec = tonic_prost::ProstCodec::default();
1531            let path = http::uri::PathAndQuery::from_static(
1532                "/rime.SpeechToText/TranscribeStreaming",
1533            );
1534            let mut req = request.into_streaming_request();
1535            req.extensions_mut()
1536                .insert(GrpcMethod::new("rime.SpeechToText", "TranscribeStreaming"));
1537            self.inner.streaming(req, path, codec).await
1538        }
1539    }
1540}
1541/// Generated server implementations.
1542#[cfg(feature = "grpc")]
1543pub mod speech_to_text_server {
1544    #![allow(
1545        unused_variables,
1546        dead_code,
1547        missing_docs,
1548        clippy::wildcard_imports,
1549        clippy::let_unit_value,
1550    )]
1551    use tonic::codegen::*;
1552    /// Generated trait containing gRPC methods that should be implemented for use with SpeechToTextServer.
1553    #[async_trait]
1554    pub trait SpeechToText: std::marker::Send + std::marker::Sync + 'static {
1555        /// Transcribes one complete WAV payload. Language and formatting mode are
1556        /// available for the whole-utterance model path.
1557        async fn transcribe(
1558            &self,
1559            request: tonic::Request<super::TranscriptionRequest>,
1560        ) -> std::result::Result<
1561            tonic::Response<super::TranscriptionResponse>,
1562            tonic::Status,
1563        >;
1564        /// Server streaming response type for the TranscribeStreaming method.
1565        type TranscribeStreamingStream: tonic::codegen::tokio_stream::Stream<
1566                Item = std::result::Result<
1567                    super::StreamingTranscriptionResponse,
1568                    tonic::Status,
1569                >,
1570            >
1571            + std::marker::Send
1572            + 'static;
1573        /// Transcribes exactly one realtime PCM16 mono 16 kHz utterance per client
1574        /// stream. The first request must contain `config`; following requests contain
1575        /// audio. Client half-close commits the utterance and produces one final `done`
1576        /// response. Dropping either side of the RPC cancels the associated backend
1577        /// work.
1578        async fn transcribe_streaming(
1579            &self,
1580            request: tonic::Request<
1581                tonic::Streaming<super::StreamingTranscriptionRequest>,
1582            >,
1583        ) -> std::result::Result<
1584            tonic::Response<Self::TranscribeStreamingStream>,
1585            tonic::Status,
1586        >;
1587    }
1588    /// Whole-utterance and realtime speech recognition for Cassowary. Cassowary
1589    /// adapts this public contract to the native vLLM chat API; vLLM owns model
1590    /// loading, inference, and GPU scheduling.
1591    #[derive(Debug)]
1592    pub struct SpeechToTextServer<T> {
1593        inner: Arc<T>,
1594        accept_compression_encodings: EnabledCompressionEncodings,
1595        send_compression_encodings: EnabledCompressionEncodings,
1596        max_decoding_message_size: Option<usize>,
1597        max_encoding_message_size: Option<usize>,
1598    }
1599    impl<T> SpeechToTextServer<T> {
1600        pub fn new(inner: T) -> Self {
1601            Self::from_arc(Arc::new(inner))
1602        }
1603        pub fn from_arc(inner: Arc<T>) -> Self {
1604            Self {
1605                inner,
1606                accept_compression_encodings: Default::default(),
1607                send_compression_encodings: Default::default(),
1608                max_decoding_message_size: None,
1609                max_encoding_message_size: None,
1610            }
1611        }
1612        pub fn with_interceptor<F>(
1613            inner: T,
1614            interceptor: F,
1615        ) -> InterceptedService<Self, F>
1616        where
1617            F: tonic::service::Interceptor,
1618        {
1619            InterceptedService::new(Self::new(inner), interceptor)
1620        }
1621        /// Enable decompressing requests with the given encoding.
1622        #[must_use]
1623        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
1624            self.accept_compression_encodings.enable(encoding);
1625            self
1626        }
1627        /// Compress responses with the given encoding, if the client supports it.
1628        #[must_use]
1629        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
1630            self.send_compression_encodings.enable(encoding);
1631            self
1632        }
1633        /// Limits the maximum size of a decoded message.
1634        ///
1635        /// Default: `4MB`
1636        #[must_use]
1637        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
1638            self.max_decoding_message_size = Some(limit);
1639            self
1640        }
1641        /// Limits the maximum size of an encoded message.
1642        ///
1643        /// Default: `usize::MAX`
1644        #[must_use]
1645        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
1646            self.max_encoding_message_size = Some(limit);
1647            self
1648        }
1649    }
1650    impl<T, B> tonic::codegen::Service<http::Request<B>> for SpeechToTextServer<T>
1651    where
1652        T: SpeechToText,
1653        B: Body + std::marker::Send + 'static,
1654        B::Error: Into<StdError> + std::marker::Send + 'static,
1655    {
1656        type Response = http::Response<tonic::body::Body>;
1657        type Error = std::convert::Infallible;
1658        type Future = BoxFuture<Self::Response, Self::Error>;
1659        fn poll_ready(
1660            &mut self,
1661            _cx: &mut Context<'_>,
1662        ) -> Poll<std::result::Result<(), Self::Error>> {
1663            Poll::Ready(Ok(()))
1664        }
1665        fn call(&mut self, req: http::Request<B>) -> Self::Future {
1666            match req.uri().path() {
1667                "/rime.SpeechToText/Transcribe" => {
1668                    #[allow(non_camel_case_types)]
1669                    struct TranscribeSvc<T: SpeechToText>(pub Arc<T>);
1670                    impl<
1671                        T: SpeechToText,
1672                    > tonic::server::UnaryService<super::TranscriptionRequest>
1673                    for TranscribeSvc<T> {
1674                        type Response = super::TranscriptionResponse;
1675                        type Future = BoxFuture<
1676                            tonic::Response<Self::Response>,
1677                            tonic::Status,
1678                        >;
1679                        fn call(
1680                            &mut self,
1681                            request: tonic::Request<super::TranscriptionRequest>,
1682                        ) -> Self::Future {
1683                            let inner = Arc::clone(&self.0);
1684                            let fut = async move {
1685                                <T as SpeechToText>::transcribe(&inner, request).await
1686                            };
1687                            Box::pin(fut)
1688                        }
1689                    }
1690                    let accept_compression_encodings = self.accept_compression_encodings;
1691                    let send_compression_encodings = self.send_compression_encodings;
1692                    let max_decoding_message_size = self.max_decoding_message_size;
1693                    let max_encoding_message_size = self.max_encoding_message_size;
1694                    let inner = self.inner.clone();
1695                    let fut = async move {
1696                        let method = TranscribeSvc(inner);
1697                        let codec = tonic_prost::ProstCodec::default();
1698                        let mut grpc = tonic::server::Grpc::new(codec)
1699                            .apply_compression_config(
1700                                accept_compression_encodings,
1701                                send_compression_encodings,
1702                            )
1703                            .apply_max_message_size_config(
1704                                max_decoding_message_size,
1705                                max_encoding_message_size,
1706                            );
1707                        let res = grpc.unary(method, req).await;
1708                        Ok(res)
1709                    };
1710                    Box::pin(fut)
1711                }
1712                "/rime.SpeechToText/TranscribeStreaming" => {
1713                    #[allow(non_camel_case_types)]
1714                    struct TranscribeStreamingSvc<T: SpeechToText>(pub Arc<T>);
1715                    impl<
1716                        T: SpeechToText,
1717                    > tonic::server::StreamingService<
1718                        super::StreamingTranscriptionRequest,
1719                    > for TranscribeStreamingSvc<T> {
1720                        type Response = super::StreamingTranscriptionResponse;
1721                        type ResponseStream = T::TranscribeStreamingStream;
1722                        type Future = BoxFuture<
1723                            tonic::Response<Self::ResponseStream>,
1724                            tonic::Status,
1725                        >;
1726                        fn call(
1727                            &mut self,
1728                            request: tonic::Request<
1729                                tonic::Streaming<super::StreamingTranscriptionRequest>,
1730                            >,
1731                        ) -> Self::Future {
1732                            let inner = Arc::clone(&self.0);
1733                            let fut = async move {
1734                                <T as SpeechToText>::transcribe_streaming(&inner, request)
1735                                    .await
1736                            };
1737                            Box::pin(fut)
1738                        }
1739                    }
1740                    let accept_compression_encodings = self.accept_compression_encodings;
1741                    let send_compression_encodings = self.send_compression_encodings;
1742                    let max_decoding_message_size = self.max_decoding_message_size;
1743                    let max_encoding_message_size = self.max_encoding_message_size;
1744                    let inner = self.inner.clone();
1745                    let fut = async move {
1746                        let method = TranscribeStreamingSvc(inner);
1747                        let codec = tonic_prost::ProstCodec::default();
1748                        let mut grpc = tonic::server::Grpc::new(codec)
1749                            .apply_compression_config(
1750                                accept_compression_encodings,
1751                                send_compression_encodings,
1752                            )
1753                            .apply_max_message_size_config(
1754                                max_decoding_message_size,
1755                                max_encoding_message_size,
1756                            );
1757                        let res = grpc.streaming(method, req).await;
1758                        Ok(res)
1759                    };
1760                    Box::pin(fut)
1761                }
1762                _ => {
1763                    Box::pin(async move {
1764                        let mut response = http::Response::new(
1765                            tonic::body::Body::default(),
1766                        );
1767                        let headers = response.headers_mut();
1768                        headers
1769                            .insert(
1770                                tonic::Status::GRPC_STATUS,
1771                                (tonic::Code::Unimplemented as i32).into(),
1772                            );
1773                        headers
1774                            .insert(
1775                                http::header::CONTENT_TYPE,
1776                                tonic::metadata::GRPC_CONTENT_TYPE,
1777                            );
1778                        Ok(response)
1779                    })
1780                }
1781            }
1782        }
1783    }
1784    impl<T> Clone for SpeechToTextServer<T> {
1785        fn clone(&self) -> Self {
1786            let inner = self.inner.clone();
1787            Self {
1788                inner,
1789                accept_compression_encodings: self.accept_compression_encodings,
1790                send_compression_encodings: self.send_compression_encodings,
1791                max_decoding_message_size: self.max_decoding_message_size,
1792                max_encoding_message_size: self.max_encoding_message_size,
1793            }
1794        }
1795    }
1796    /// Generated gRPC service name
1797    pub const SERVICE_NAME: &str = "rime.SpeechToText";
1798    impl<T> tonic::server::NamedService for SpeechToTextServer<T> {
1799        const NAME: &'static str = SERVICE_NAME;
1800    }
1801}