|
| 1 | +// |
| 2 | +// DO NOT EDIT. |
| 3 | +// |
| 4 | +// Generated by the protocol buffer compiler. |
| 5 | +// Source: speechly/moderation/v1beta1/moderation_api.proto |
| 6 | +// |
| 7 | + |
| 8 | +// |
| 9 | +// Copyright 2018, gRPC Authors All rights reserved. |
| 10 | +// |
| 11 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 12 | +// you may not use this file except in compliance with the License. |
| 13 | +// You may obtain a copy of the License at |
| 14 | +// |
| 15 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 16 | +// |
| 17 | +// Unless required by applicable law or agreed to in writing, software |
| 18 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 19 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 20 | +// See the License for the specific language governing permissions and |
| 21 | +// limitations under the License. |
| 22 | +// |
| 23 | +import GRPC |
| 24 | +import NIO |
| 25 | +import SwiftProtobuf |
| 26 | + |
| 27 | + |
| 28 | +/// Run Speechly Moderation API with streamable audio content or text content. |
| 29 | +/// |
| 30 | +/// Usage: instantiate `Speechly_Moderation_V1beta1_ModerationAPIClient`, then call methods of this protocol to make API calls. |
| 31 | +public protocol Speechly_Moderation_V1beta1_ModerationAPIClientProtocol: GRPCClient { |
| 32 | + var serviceName: String { get } |
| 33 | + var interceptors: Speechly_Moderation_V1beta1_ModerationAPIClientInterceptorFactoryProtocol? { get } |
| 34 | + |
| 35 | + func audioModeration( |
| 36 | + callOptions: CallOptions? |
| 37 | + ) -> ClientStreamingCall<Speechly_Moderation_V1beta1_AudioModerationRequest, Speechly_Moderation_V1beta1_AudioModerationResponse> |
| 38 | + |
| 39 | + func streamingAudioModeration( |
| 40 | + callOptions: CallOptions?, |
| 41 | + handler: @escaping (Speechly_Moderation_V1beta1_StreamingAudioModerationResponse) -> Void |
| 42 | + ) -> BidirectionalStreamingCall<Speechly_Moderation_V1beta1_StreamingAudioModerationRequest, Speechly_Moderation_V1beta1_StreamingAudioModerationResponse> |
| 43 | + |
| 44 | + func textModeration( |
| 45 | + _ request: Speechly_Moderation_V1beta1_TextModerationRequest, |
| 46 | + callOptions: CallOptions? |
| 47 | + ) -> UnaryCall<Speechly_Moderation_V1beta1_TextModerationRequest, Speechly_Moderation_V1beta1_TextModerationResponse> |
| 48 | +} |
| 49 | + |
| 50 | +extension Speechly_Moderation_V1beta1_ModerationAPIClientProtocol { |
| 51 | + public var serviceName: String { |
| 52 | + return "speechly.moderation.v1beta1.ModerationAPI" |
| 53 | + } |
| 54 | + |
| 55 | + /// Stream audio to be moderated and receive all results once whole audio has been processed. |
| 56 | + /// The discourse context may be described for improved performance. |
| 57 | + /// Audio must be in a format supported for Live Streaming, see https://docs.speechly.com/features/audio-formats |
| 58 | + /// |
| 59 | + /// Callers should use the `send` method on the returned object to send messages |
| 60 | + /// to the server. The caller should send an `.end` after the final message has been sent. |
| 61 | + /// |
| 62 | + /// - Parameters: |
| 63 | + /// - callOptions: Call options. |
| 64 | + /// - Returns: A `ClientStreamingCall` with futures for the metadata, status and response. |
| 65 | + public func audioModeration( |
| 66 | + callOptions: CallOptions? = nil |
| 67 | + ) -> ClientStreamingCall<Speechly_Moderation_V1beta1_AudioModerationRequest, Speechly_Moderation_V1beta1_AudioModerationResponse> { |
| 68 | + return self.makeClientStreamingCall( |
| 69 | + path: "/speechly.moderation.v1beta1.ModerationAPI/AudioModeration", |
| 70 | + callOptions: callOptions ?? self.defaultCallOptions, |
| 71 | + interceptors: self.interceptors?.makeAudioModerationInterceptors() ?? [] |
| 72 | + ) |
| 73 | + } |
| 74 | + |
| 75 | + /// Stream audio to be moderated and receive results for identified segments as soon results as possible. |
| 76 | + /// The discourse context may be described for improved performance. |
| 77 | + /// Audio must be in a format supported for Live Streaming, see https://docs.speechly.com/features/audio-formats |
| 78 | + /// |
| 79 | + /// Callers should use the `send` method on the returned object to send messages |
| 80 | + /// to the server. The caller should send an `.end` after the final message has been sent. |
| 81 | + /// |
| 82 | + /// - Parameters: |
| 83 | + /// - callOptions: Call options. |
| 84 | + /// - handler: A closure called when each response is received from the server. |
| 85 | + /// - Returns: A `ClientStreamingCall` with futures for the metadata and status. |
| 86 | + public func streamingAudioModeration( |
| 87 | + callOptions: CallOptions? = nil, |
| 88 | + handler: @escaping (Speechly_Moderation_V1beta1_StreamingAudioModerationResponse) -> Void |
| 89 | + ) -> BidirectionalStreamingCall<Speechly_Moderation_V1beta1_StreamingAudioModerationRequest, Speechly_Moderation_V1beta1_StreamingAudioModerationResponse> { |
| 90 | + return self.makeBidirectionalStreamingCall( |
| 91 | + path: "/speechly.moderation.v1beta1.ModerationAPI/StreamingAudioModeration", |
| 92 | + callOptions: callOptions ?? self.defaultCallOptions, |
| 93 | + interceptors: self.interceptors?.makeStreamingAudioModerationInterceptors() ?? [], |
| 94 | + handler: handler |
| 95 | + ) |
| 96 | + } |
| 97 | + |
| 98 | + /// Moderate a text utterance. |
| 99 | + /// The discourse context may be described for improved performance. |
| 100 | + /// The related audio may be identified using `audio_context_id`. |
| 101 | + /// |
| 102 | + /// - Parameters: |
| 103 | + /// - request: Request to send to TextModeration. |
| 104 | + /// - callOptions: Call options. |
| 105 | + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. |
| 106 | + public func textModeration( |
| 107 | + _ request: Speechly_Moderation_V1beta1_TextModerationRequest, |
| 108 | + callOptions: CallOptions? = nil |
| 109 | + ) -> UnaryCall<Speechly_Moderation_V1beta1_TextModerationRequest, Speechly_Moderation_V1beta1_TextModerationResponse> { |
| 110 | + return self.makeUnaryCall( |
| 111 | + path: "/speechly.moderation.v1beta1.ModerationAPI/TextModeration", |
| 112 | + request: request, |
| 113 | + callOptions: callOptions ?? self.defaultCallOptions, |
| 114 | + interceptors: self.interceptors?.makeTextModerationInterceptors() ?? [] |
| 115 | + ) |
| 116 | + } |
| 117 | +} |
| 118 | + |
| 119 | +public protocol Speechly_Moderation_V1beta1_ModerationAPIClientInterceptorFactoryProtocol { |
| 120 | + |
| 121 | + /// - Returns: Interceptors to use when invoking 'audioModeration'. |
| 122 | + func makeAudioModerationInterceptors() -> [ClientInterceptor<Speechly_Moderation_V1beta1_AudioModerationRequest, Speechly_Moderation_V1beta1_AudioModerationResponse>] |
| 123 | + |
| 124 | + /// - Returns: Interceptors to use when invoking 'streamingAudioModeration'. |
| 125 | + func makeStreamingAudioModerationInterceptors() -> [ClientInterceptor<Speechly_Moderation_V1beta1_StreamingAudioModerationRequest, Speechly_Moderation_V1beta1_StreamingAudioModerationResponse>] |
| 126 | + |
| 127 | + /// - Returns: Interceptors to use when invoking 'textModeration'. |
| 128 | + func makeTextModerationInterceptors() -> [ClientInterceptor<Speechly_Moderation_V1beta1_TextModerationRequest, Speechly_Moderation_V1beta1_TextModerationResponse>] |
| 129 | +} |
| 130 | + |
| 131 | +public final class Speechly_Moderation_V1beta1_ModerationAPIClient: Speechly_Moderation_V1beta1_ModerationAPIClientProtocol { |
| 132 | + public let channel: GRPCChannel |
| 133 | + public var defaultCallOptions: CallOptions |
| 134 | + public var interceptors: Speechly_Moderation_V1beta1_ModerationAPIClientInterceptorFactoryProtocol? |
| 135 | + |
| 136 | + /// Creates a client for the speechly.moderation.v1beta1.ModerationAPI service. |
| 137 | + /// |
| 138 | + /// - Parameters: |
| 139 | + /// - channel: `GRPCChannel` to the service host. |
| 140 | + /// - defaultCallOptions: Options to use for each service call if the user doesn't provide them. |
| 141 | + /// - interceptors: A factory providing interceptors for each RPC. |
| 142 | + public init( |
| 143 | + channel: GRPCChannel, |
| 144 | + defaultCallOptions: CallOptions = CallOptions(), |
| 145 | + interceptors: Speechly_Moderation_V1beta1_ModerationAPIClientInterceptorFactoryProtocol? = nil |
| 146 | + ) { |
| 147 | + self.channel = channel |
| 148 | + self.defaultCallOptions = defaultCallOptions |
| 149 | + self.interceptors = interceptors |
| 150 | + } |
| 151 | +} |
| 152 | + |
| 153 | +/// Run Speechly Moderation API with streamable audio content or text content. |
| 154 | +/// |
| 155 | +/// To build a server, implement a class that conforms to this protocol. |
| 156 | +public protocol Speechly_Moderation_V1beta1_ModerationAPIProvider: CallHandlerProvider { |
| 157 | + var interceptors: Speechly_Moderation_V1beta1_ModerationAPIServerInterceptorFactoryProtocol? { get } |
| 158 | + |
| 159 | + /// Stream audio to be moderated and receive all results once whole audio has been processed. |
| 160 | + /// The discourse context may be described for improved performance. |
| 161 | + /// Audio must be in a format supported for Live Streaming, see https://docs.speechly.com/features/audio-formats |
| 162 | + func audioModeration(context: UnaryResponseCallContext<Speechly_Moderation_V1beta1_AudioModerationResponse>) -> EventLoopFuture<(StreamEvent<Speechly_Moderation_V1beta1_AudioModerationRequest>) -> Void> |
| 163 | + |
| 164 | + /// Stream audio to be moderated and receive results for identified segments as soon results as possible. |
| 165 | + /// The discourse context may be described for improved performance. |
| 166 | + /// Audio must be in a format supported for Live Streaming, see https://docs.speechly.com/features/audio-formats |
| 167 | + func streamingAudioModeration(context: StreamingResponseCallContext<Speechly_Moderation_V1beta1_StreamingAudioModerationResponse>) -> EventLoopFuture<(StreamEvent<Speechly_Moderation_V1beta1_StreamingAudioModerationRequest>) -> Void> |
| 168 | + |
| 169 | + /// Moderate a text utterance. |
| 170 | + /// The discourse context may be described for improved performance. |
| 171 | + /// The related audio may be identified using `audio_context_id`. |
| 172 | + func textModeration(request: Speechly_Moderation_V1beta1_TextModerationRequest, context: StatusOnlyCallContext) -> EventLoopFuture<Speechly_Moderation_V1beta1_TextModerationResponse> |
| 173 | +} |
| 174 | + |
| 175 | +extension Speechly_Moderation_V1beta1_ModerationAPIProvider { |
| 176 | + public var serviceName: Substring { return "speechly.moderation.v1beta1.ModerationAPI" } |
| 177 | + |
| 178 | + /// Determines, calls and returns the appropriate request handler, depending on the request's method. |
| 179 | + /// Returns nil for methods not handled by this service. |
| 180 | + public func handle( |
| 181 | + method name: Substring, |
| 182 | + context: CallHandlerContext |
| 183 | + ) -> GRPCServerHandlerProtocol? { |
| 184 | + switch name { |
| 185 | + case "AudioModeration": |
| 186 | + return ClientStreamingServerHandler( |
| 187 | + context: context, |
| 188 | + requestDeserializer: ProtobufDeserializer<Speechly_Moderation_V1beta1_AudioModerationRequest>(), |
| 189 | + responseSerializer: ProtobufSerializer<Speechly_Moderation_V1beta1_AudioModerationResponse>(), |
| 190 | + interceptors: self.interceptors?.makeAudioModerationInterceptors() ?? [], |
| 191 | + observerFactory: self.audioModeration(context:) |
| 192 | + ) |
| 193 | + |
| 194 | + case "StreamingAudioModeration": |
| 195 | + return BidirectionalStreamingServerHandler( |
| 196 | + context: context, |
| 197 | + requestDeserializer: ProtobufDeserializer<Speechly_Moderation_V1beta1_StreamingAudioModerationRequest>(), |
| 198 | + responseSerializer: ProtobufSerializer<Speechly_Moderation_V1beta1_StreamingAudioModerationResponse>(), |
| 199 | + interceptors: self.interceptors?.makeStreamingAudioModerationInterceptors() ?? [], |
| 200 | + observerFactory: self.streamingAudioModeration(context:) |
| 201 | + ) |
| 202 | + |
| 203 | + case "TextModeration": |
| 204 | + return UnaryServerHandler( |
| 205 | + context: context, |
| 206 | + requestDeserializer: ProtobufDeserializer<Speechly_Moderation_V1beta1_TextModerationRequest>(), |
| 207 | + responseSerializer: ProtobufSerializer<Speechly_Moderation_V1beta1_TextModerationResponse>(), |
| 208 | + interceptors: self.interceptors?.makeTextModerationInterceptors() ?? [], |
| 209 | + userFunction: self.textModeration(request:context:) |
| 210 | + ) |
| 211 | + |
| 212 | + default: |
| 213 | + return nil |
| 214 | + } |
| 215 | + } |
| 216 | +} |
| 217 | + |
| 218 | +public protocol Speechly_Moderation_V1beta1_ModerationAPIServerInterceptorFactoryProtocol { |
| 219 | + |
| 220 | + /// - Returns: Interceptors to use when handling 'audioModeration'. |
| 221 | + /// Defaults to calling `self.makeInterceptors()`. |
| 222 | + func makeAudioModerationInterceptors() -> [ServerInterceptor<Speechly_Moderation_V1beta1_AudioModerationRequest, Speechly_Moderation_V1beta1_AudioModerationResponse>] |
| 223 | + |
| 224 | + /// - Returns: Interceptors to use when handling 'streamingAudioModeration'. |
| 225 | + /// Defaults to calling `self.makeInterceptors()`. |
| 226 | + func makeStreamingAudioModerationInterceptors() -> [ServerInterceptor<Speechly_Moderation_V1beta1_StreamingAudioModerationRequest, Speechly_Moderation_V1beta1_StreamingAudioModerationResponse>] |
| 227 | + |
| 228 | + /// - Returns: Interceptors to use when handling 'textModeration'. |
| 229 | + /// Defaults to calling `self.makeInterceptors()`. |
| 230 | + func makeTextModerationInterceptors() -> [ServerInterceptor<Speechly_Moderation_V1beta1_TextModerationRequest, Speechly_Moderation_V1beta1_TextModerationResponse>] |
| 231 | +} |
0 commit comments