diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c16f218 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +.DS_Store +/.build +/Packages +/*.xcodeproj +xcuserdata/ +protoc_plugins/ diff --git a/Makefile b/Makefile index 64aea1c..15e9ee4 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,43 @@ -build: +PROTOS := $(shell find ./speechly -name *.proto) +SWIFT_PROTOS_DIR := ./Sources/SpeechlyAPI +SWIFT_BUILD_DIR := ./.build +SWIFT_LIB_VERSION := 1.0.0-alpha.20 +SWIFT_PLUGINS_DIR := ./protoc_plugins +SWIFT_PROTOC_GEN_SWIFT := $(SWIFT_PLUGINS_DIR)/bin/protoc-gen-swift +SWIFT_PROTOC_GEN_GRPC_SWIFT := $(SWIFT_PLUGINS_DIR)/bin/protoc-gen-grpc-swift + +build: build-swift @echo "Generating code stubs" @make -C go @make -C python @make -C javascript .PHONY: build + +build-swift: $(SWIFT_BUILD_DIR) +.PHONY: build-swift + +clean-swift: + @rm -rf $(SWIFT_BUILD_DIR) $(SWIFT_PROTOS_DIR) $(SWIFT_PLUGINS_DIR) || true +.PHONY: clean-swift + +$(SWIFT_BUILD_DIR): $(SWIFT_PROTOS_DIR) + @swift build + @touch $@ + +$(SWIFT_PROTOS_DIR): $(PROTOS) $(SWIFT_PLUGINS_DIR) + @mkdir -p $(SWIFT_PROTOS_DIR) + @protoc \ + -I . \ + --plugin=$(SWIFT_PROTOC_GEN_SWIFT) \ + --plugin=$(SWIFT_PROTOC_GEN_GRPC_SWIFT) \ + --swift_out="$(SWIFT_PROTOS_DIR)" \ + --swift_opt=Visibility=Public \ + --grpc-swift_out="$(SWIFT_PROTOS_DIR)" \ + --grpc-swift_opt=Visibility=Public \ + $(PROTOS) + +$(SWIFT_PLUGINS_DIR): + @mkdir $(SWIFT_PLUGINS_DIR) + @curl -L https://github.com/grpc/grpc-swift/releases/download/$(SWIFT_LIB_VERSION)/protoc-grpc-swift-plugins-$(SWIFT_LIB_VERSION).zip -o $(SWIFT_PLUGINS_DIR)/plugins.zip + @unzip $(SWIFT_PLUGINS_DIR)/plugins.zip -d $(SWIFT_PLUGINS_DIR) + @rm $(SWIFT_PLUGINS_DIR)/plugins.zip diff --git a/Package.resolved b/Package.resolved new file mode 100644 index 0000000..971eb57 --- /dev/null +++ b/Package.resolved @@ -0,0 +1,70 @@ +{ + "object": { + "pins": [ + { + "package": "grpc-swift", + "repositoryURL": "https://github.com/grpc/grpc-swift.git", + "state": { + "branch": null, + "revision": "e2e138df61dcbfc2dc1cf284fdab6f983539ab48", + "version": "1.0.0-alpha.20" + } + }, + { + "package": "swift-log", + "repositoryURL": "https://github.com/apple/swift-log.git", + "state": { + "branch": null, + "revision": "173f567a2dfec11d74588eea82cecea555bdc0bc", + "version": "1.4.0" + } + }, + { + "package": "swift-nio", + "repositoryURL": "https://github.com/apple/swift-nio.git", + "state": { + "branch": null, + "revision": "c3e2359c55cd8b47207ab7363b77c9c398a95294", + "version": "2.23.0" + } + }, + { + "package": "swift-nio-http2", + "repositoryURL": "https://github.com/apple/swift-nio-http2.git", + "state": { + "branch": null, + "revision": "78ddbdfca10f64e4399da37c63372fd8db232152", + "version": "1.15.0" + } + }, + { + "package": "swift-nio-ssl", + "repositoryURL": "https://github.com/apple/swift-nio-ssl.git", + "state": { + "branch": null, + "revision": "eb102ad32add8638410e37a69bc815ea11379813", + "version": "2.10.0" + } + }, + { + "package": "swift-nio-transport-services", + "repositoryURL": "https://github.com/apple/swift-nio-transport-services.git", + "state": { + "branch": null, + "revision": "bb56586c4cab9a79dce6ec4738baddb5802c5de7", + "version": "1.9.0" + } + }, + { + "package": "SwiftProtobuf", + "repositoryURL": "https://github.com/apple/swift-protobuf.git", + "state": { + "branch": null, + "revision": "0279688c9fc5a40028e1b5bb0cb56534a45a6020", + "version": "1.12.0" + } + } + ] + }, + "version": 1 +} diff --git a/Package.swift b/Package.swift new file mode 100644 index 0000000..beced81 --- /dev/null +++ b/Package.swift @@ -0,0 +1,22 @@ +// swift-tools-version:5.3 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "speechly-api", + products: [ + .library(name: "SpeechlyAPI", targets: ["SpeechlyAPI"]), + ], + dependencies: [ + .package(url: "https://github.com/grpc/grpc-swift.git", from: "1.0.0-alpha.20"), + ], + targets: [ + .target( + name: "SpeechlyAPI", + dependencies: [ + .product(name: "GRPC", package: "grpc-swift"), + ] + ), + ] +) diff --git a/README.md b/README.md index 8a84450..485dfd5 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ This repository stores the definitions and generated code for Speechly public AP Protocol buffers definitions are located in `speechly/`. -Generated Go code and the module is located in `go/`, Python code and package in `python/`, Javascript code and package in `javascript/`. +Generated Go code and the module is located in `go/`, Python code and package in `python/`, Javascript code and package in `javascript/` and Swift code in `Sources/`. Swift Package Manager requires the manifest to be in the root of the repository, hence why Swift code is not put into its dedicated subdirectory. Make sure to check language-specific READMEs. @@ -12,3 +12,69 @@ Make sure to check language-specific READMEs. You can run the build for all languages with `make build` from the root of this repo. +## Using Swift stubs + +You can add Swift stubs to your project using Swift Package Manager. Here's an example configuration: + +```swift +// swift-tools-version:5.3 + +import PackageDescription + +let package = Package( + name: "my-package", + products: [ + .executable(name: "SomeName", targets: ["SomeTarget"]), + ], + dependencies: [ + .package(url: "https://github.com/speechly/api.git", from: "1.0.0-alpha.1"), + ], + targets: [ + .target( + name: "SomeTarget", + dependencies: [ + .product(name: "SpeechlyAPI", package: "speechly-api"), + ]), + ] +) +``` + +Thereafter you can use the stubs in your code (you will most likely need to add `grpc-swift` and `swift-nio` dependencies to write gRPC clients): + +```swift +import NIO +import GRPC +import SpeechlyAPI + +class IdentityClient { + let client: SpeechlyAPI.Speechly_Identity_V1_IdentityClient + + init() { + let group = GRPC.PlatformSupport.makeEventLoopGroup(loopCount: 1) + let channel = GRPC.ClientConnection.secure(group: group).connect(host: "api.speechly.com", port: 443) + + self.client = SpeechlyAPI.Speechly_Identity_V1_IdentityClient(channel: channel) + } + + func login(appId: String, deviceId: String) -> NIO.EventLoopFuture { + let request = SpeechlyAPI.Speechly_Identity_V1_LoginRequest.with { + $0.appID = appId + $0.deviceID = deviceId + } + + return self.client.login(request).response.map({ (response: SpeechlyAPI.Speechly_Identity_V1_LoginResponse) -> String in + return response.token + }) + } + + deinit { + let future = self.client.channel.close() + + do { + try future.wait() + } catch { + print("Error closing gRPC channel: \(error)") + } + } +} +``` diff --git a/Sources/SpeechlyAPI/speechly/config/v1/config_api.grpc.swift b/Sources/SpeechlyAPI/speechly/config/v1/config_api.grpc.swift new file mode 100644 index 0000000..b7f268f --- /dev/null +++ b/Sources/SpeechlyAPI/speechly/config/v1/config_api.grpc.swift @@ -0,0 +1,475 @@ +// +// DO NOT EDIT. +// +// Generated by the protocol buffer compiler. +// Source: speechly/config/v1/config_api.proto +// + +// +// Copyright 2018, gRPC Authors All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +import GRPC +import NIO +import SwiftProtobuf + + +/// Usage: instantiate Speechly_Config_V1_ConfigAPIClient, then call methods of this protocol to make API calls. +public protocol Speechly_Config_V1_ConfigAPIClientProtocol: GRPCClient { + func getProject( + _ request: Speechly_Config_V1_GetProjectRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func createProject( + _ request: Speechly_Config_V1_CreateProjectRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func updateProject( + _ request: Speechly_Config_V1_UpdateProjectRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func getProjectParticipants( + _ request: Speechly_Config_V1_GetProjectParticipantsRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func invite( + _ request: Speechly_Config_V1_InviteRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func joinProject( + _ request: Speechly_Config_V1_JoinProjectRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func listApps( + _ request: Speechly_Config_V1_ListAppsRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func getApp( + _ request: Speechly_Config_V1_GetAppRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func createApp( + _ request: Speechly_Config_V1_CreateAppRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func updateApp( + _ request: Speechly_Config_V1_UpdateAppRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func deleteApp( + _ request: Speechly_Config_V1_DeleteAppRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func uploadTrainingData( + callOptions: CallOptions? + ) -> ClientStreamingCall + + func downloadCurrentTrainingData( + _ request: Speechly_Config_V1_DownloadCurrentTrainingDataRequest, + callOptions: CallOptions?, + handler: @escaping (Speechly_Config_V1_DownloadCurrentTrainingDataResponse) -> Void + ) -> ServerStreamingCall + +} + +extension Speechly_Config_V1_ConfigAPIClientProtocol { + + /// Lists all current user projects. + /// + /// - Parameters: + /// - request: Request to send to GetProject. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func getProject( + _ request: Speechly_Config_V1_GetProjectRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return self.makeUnaryCall( + path: "/speechly.config.v1.ConfigAPI/GetProject", + request: request, + callOptions: callOptions ?? self.defaultCallOptions + ) + } + + /// Creates a new project for current user. + /// + /// - Parameters: + /// - request: Request to send to CreateProject. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func createProject( + _ request: Speechly_Config_V1_CreateProjectRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return self.makeUnaryCall( + path: "/speechly.config.v1.ConfigAPI/CreateProject", + request: request, + callOptions: callOptions ?? self.defaultCallOptions + ) + } + + /// Updates an existing project. + /// + /// - Parameters: + /// - request: Request to send to UpdateProject. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func updateProject( + _ request: Speechly_Config_V1_UpdateProjectRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return self.makeUnaryCall( + path: "/speechly.config.v1.ConfigAPI/UpdateProject", + request: request, + callOptions: callOptions ?? self.defaultCallOptions + ) + } + + /// Lists all users with access to a project. + /// + /// - Parameters: + /// - request: Request to send to GetProjectParticipants. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func getProjectParticipants( + _ request: Speechly_Config_V1_GetProjectParticipantsRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return self.makeUnaryCall( + path: "/speechly.config.v1.ConfigAPI/GetProjectParticipants", + request: request, + callOptions: callOptions ?? self.defaultCallOptions + ) + } + + /// Generates an invitation link for another user to join a project, + /// which can be used to call JoinProject. + /// + /// - Parameters: + /// - request: Request to send to Invite. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func invite( + _ request: Speechly_Config_V1_InviteRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return self.makeUnaryCall( + path: "/speechly.config.v1.ConfigAPI/Invite", + request: request, + callOptions: callOptions ?? self.defaultCallOptions + ) + } + + /// Joins a project as a current user. + /// Requires a link generated with `Invite`. + /// + /// - Parameters: + /// - request: Request to send to JoinProject. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func joinProject( + _ request: Speechly_Config_V1_JoinProjectRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return self.makeUnaryCall( + path: "/speechly.config.v1.ConfigAPI/JoinProject", + request: request, + callOptions: callOptions ?? self.defaultCallOptions + ) + } + + /// Lists all applications in a project. + /// + /// - Parameters: + /// - request: Request to send to ListApps. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func listApps( + _ request: Speechly_Config_V1_ListAppsRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return self.makeUnaryCall( + path: "/speechly.config.v1.ConfigAPI/ListApps", + request: request, + callOptions: callOptions ?? self.defaultCallOptions + ) + } + + /// Gets detailed information about an application. + /// + /// - Parameters: + /// - request: Request to send to GetApp. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func getApp( + _ request: Speechly_Config_V1_GetAppRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return self.makeUnaryCall( + path: "/speechly.config.v1.ConfigAPI/GetApp", + request: request, + callOptions: callOptions ?? self.defaultCallOptions + ) + } + + /// Creates a new application for current user. + /// + /// - Parameters: + /// - request: Request to send to CreateApp. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func createApp( + _ request: Speechly_Config_V1_CreateAppRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return self.makeUnaryCall( + path: "/speechly.config.v1.ConfigAPI/CreateApp", + request: request, + callOptions: callOptions ?? self.defaultCallOptions + ) + } + + /// Updates an existing application. + /// + /// - Parameters: + /// - request: Request to send to UpdateApp. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func updateApp( + _ request: Speechly_Config_V1_UpdateAppRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return self.makeUnaryCall( + path: "/speechly.config.v1.ConfigAPI/UpdateApp", + request: request, + callOptions: callOptions ?? self.defaultCallOptions + ) + } + + /// Deletes an existing application. + /// + /// - Parameters: + /// - request: Request to send to DeleteApp. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func deleteApp( + _ request: Speechly_Config_V1_DeleteAppRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return self.makeUnaryCall( + path: "/speechly.config.v1.ConfigAPI/DeleteApp", + request: request, + callOptions: callOptions ?? self.defaultCallOptions + ) + } + + /// Uploads new training data for an application. + /// This will create and queue a new training job for that application. + /// + /// Callers should use the `send` method on the returned object to send messages + /// to the server. The caller should send an `.end` after the final message has been sent. + /// + /// - Parameters: + /// - callOptions: Call options. + /// - Returns: A `ClientStreamingCall` with futures for the metadata, status and response. + public func uploadTrainingData( + callOptions: CallOptions? = nil + ) -> ClientStreamingCall { + return self.makeClientStreamingCall( + path: "/speechly.config.v1.ConfigAPI/UploadTrainingData", + callOptions: callOptions ?? self.defaultCallOptions + ) + } + + /// Downloads current training data for an application. + /// + /// - Parameters: + /// - request: Request to send to DownloadCurrentTrainingData. + /// - callOptions: Call options. + /// - handler: A closure called when each response is received from the server. + /// - Returns: A `ServerStreamingCall` with futures for the metadata and status. + public func downloadCurrentTrainingData( + _ request: Speechly_Config_V1_DownloadCurrentTrainingDataRequest, + callOptions: CallOptions? = nil, + handler: @escaping (Speechly_Config_V1_DownloadCurrentTrainingDataResponse) -> Void + ) -> ServerStreamingCall { + return self.makeServerStreamingCall( + path: "/speechly.config.v1.ConfigAPI/DownloadCurrentTrainingData", + request: request, + callOptions: callOptions ?? self.defaultCallOptions, + handler: handler + ) + } +} + +public final class Speechly_Config_V1_ConfigAPIClient: Speechly_Config_V1_ConfigAPIClientProtocol { + public let channel: GRPCChannel + public var defaultCallOptions: CallOptions + + /// Creates a client for the speechly.config.v1.ConfigAPI service. + /// + /// - Parameters: + /// - channel: `GRPCChannel` to the service host. + /// - defaultCallOptions: Options to use for each service call if the user doesn't provide them. + public init(channel: GRPCChannel, defaultCallOptions: CallOptions = CallOptions()) { + self.channel = channel + self.defaultCallOptions = defaultCallOptions + } +} + +/// To build a server, implement a class that conforms to this protocol. +public protocol Speechly_Config_V1_ConfigAPIProvider: CallHandlerProvider { + /// Lists all current user projects. + func getProject(request: Speechly_Config_V1_GetProjectRequest, context: StatusOnlyCallContext) -> EventLoopFuture + /// Creates a new project for current user. + func createProject(request: Speechly_Config_V1_CreateProjectRequest, context: StatusOnlyCallContext) -> EventLoopFuture + /// Updates an existing project. + func updateProject(request: Speechly_Config_V1_UpdateProjectRequest, context: StatusOnlyCallContext) -> EventLoopFuture + /// Lists all users with access to a project. + func getProjectParticipants(request: Speechly_Config_V1_GetProjectParticipantsRequest, context: StatusOnlyCallContext) -> EventLoopFuture + /// Generates an invitation link for another user to join a project, + /// which can be used to call JoinProject. + func invite(request: Speechly_Config_V1_InviteRequest, context: StatusOnlyCallContext) -> EventLoopFuture + /// Joins a project as a current user. + /// Requires a link generated with `Invite`. + func joinProject(request: Speechly_Config_V1_JoinProjectRequest, context: StatusOnlyCallContext) -> EventLoopFuture + /// Lists all applications in a project. + func listApps(request: Speechly_Config_V1_ListAppsRequest, context: StatusOnlyCallContext) -> EventLoopFuture + /// Gets detailed information about an application. + func getApp(request: Speechly_Config_V1_GetAppRequest, context: StatusOnlyCallContext) -> EventLoopFuture + /// Creates a new application for current user. + func createApp(request: Speechly_Config_V1_CreateAppRequest, context: StatusOnlyCallContext) -> EventLoopFuture + /// Updates an existing application. + func updateApp(request: Speechly_Config_V1_UpdateAppRequest, context: StatusOnlyCallContext) -> EventLoopFuture + /// Deletes an existing application. + func deleteApp(request: Speechly_Config_V1_DeleteAppRequest, context: StatusOnlyCallContext) -> EventLoopFuture + /// Uploads new training data for an application. + /// This will create and queue a new training job for that application. + func uploadTrainingData(context: UnaryResponseCallContext) -> EventLoopFuture<(StreamEvent) -> Void> + /// Downloads current training data for an application. + func downloadCurrentTrainingData(request: Speechly_Config_V1_DownloadCurrentTrainingDataRequest, context: StreamingResponseCallContext) -> EventLoopFuture +} + +extension Speechly_Config_V1_ConfigAPIProvider { + public var serviceName: Substring { return "speechly.config.v1.ConfigAPI" } + + /// Determines, calls and returns the appropriate request handler, depending on the request's method. + /// Returns nil for methods not handled by this service. + public func handleMethod(_ methodName: Substring, callHandlerContext: CallHandlerContext) -> GRPCCallHandler? { + switch methodName { + case "GetProject": + return CallHandlerFactory.makeUnary(callHandlerContext: callHandlerContext) { context in + return { request in + self.getProject(request: request, context: context) + } + } + + case "CreateProject": + return CallHandlerFactory.makeUnary(callHandlerContext: callHandlerContext) { context in + return { request in + self.createProject(request: request, context: context) + } + } + + case "UpdateProject": + return CallHandlerFactory.makeUnary(callHandlerContext: callHandlerContext) { context in + return { request in + self.updateProject(request: request, context: context) + } + } + + case "GetProjectParticipants": + return CallHandlerFactory.makeUnary(callHandlerContext: callHandlerContext) { context in + return { request in + self.getProjectParticipants(request: request, context: context) + } + } + + case "Invite": + return CallHandlerFactory.makeUnary(callHandlerContext: callHandlerContext) { context in + return { request in + self.invite(request: request, context: context) + } + } + + case "JoinProject": + return CallHandlerFactory.makeUnary(callHandlerContext: callHandlerContext) { context in + return { request in + self.joinProject(request: request, context: context) + } + } + + case "ListApps": + return CallHandlerFactory.makeUnary(callHandlerContext: callHandlerContext) { context in + return { request in + self.listApps(request: request, context: context) + } + } + + case "GetApp": + return CallHandlerFactory.makeUnary(callHandlerContext: callHandlerContext) { context in + return { request in + self.getApp(request: request, context: context) + } + } + + case "CreateApp": + return CallHandlerFactory.makeUnary(callHandlerContext: callHandlerContext) { context in + return { request in + self.createApp(request: request, context: context) + } + } + + case "UpdateApp": + return CallHandlerFactory.makeUnary(callHandlerContext: callHandlerContext) { context in + return { request in + self.updateApp(request: request, context: context) + } + } + + case "DeleteApp": + return CallHandlerFactory.makeUnary(callHandlerContext: callHandlerContext) { context in + return { request in + self.deleteApp(request: request, context: context) + } + } + + case "UploadTrainingData": + return CallHandlerFactory.makeClientStreaming(callHandlerContext: callHandlerContext) { context in + return self.uploadTrainingData(context: context) + } + + case "DownloadCurrentTrainingData": + return CallHandlerFactory.makeServerStreaming(callHandlerContext: callHandlerContext) { context in + return { request in + self.downloadCurrentTrainingData(request: request, context: context) + } + } + + default: return nil + } + } +} + diff --git a/Sources/SpeechlyAPI/speechly/config/v1/config_api.pb.swift b/Sources/SpeechlyAPI/speechly/config/v1/config_api.pb.swift new file mode 100644 index 0000000..8019f20 --- /dev/null +++ b/Sources/SpeechlyAPI/speechly/config/v1/config_api.pb.swift @@ -0,0 +1,1522 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: speechly/config/v1/config_api.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +import Foundation +import SwiftProtobuf + +// If the compiler emits an error on this type, it is because this file +// was generated by a version of the `protoc` Swift plug-in that is +// incompatible with the version of SwiftProtobuf to which you are linking. +// Please ensure that you are building against the same version of the API +// that was used to generate this file. +fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 +} + +/// Top-level message sent by the client for the `GetProject` method. +public struct Speechly_Config_V1_GetProjectRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// Top-level message sent by the server for the `GetProject` method. +public struct Speechly_Config_V1_GetProjectResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// A list of project IDs. + public var project: [String] = [] + + /// A list of project names in the same order as project IDs. + public var projectNames: [String] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// Top-level message sent by the client for the `CreateProject` method. +public struct Speechly_Config_V1_CreateProjectRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// An optional human-friendly name for the project. + public var name: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// Top-level message sent by the server for the `CreateProject` method. +public struct Speechly_Config_V1_CreateProjectResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// The ID of created project. + public var project: String = String() + + /// The name of created project. + public var name: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// Top-level message sent by the client for the `UpdateProject` method. +/// Currently it's only possible to update the name of the project. +public struct Speechly_Config_V1_UpdateProjectRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// The ID of the project. + public var project: String = String() + + /// New name of the project. + public var name: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// Top-level message sent by the server for the `UpdateProject` method. +public struct Speechly_Config_V1_UpdateProjectResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// Top-level message sent by the client for the `GetProjectParticipants` method. +public struct Speechly_Config_V1_GetProjectParticipantsRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// The ID of the project. + public var project: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// Top-level message sent by the server for the `GetProjectParticipants` method. +public struct Speechly_Config_V1_GetProjectParticipantsResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// A list of project's participants. + public var participants: [Speechly_Config_V1_GetProjectParticipantsResponse.Participant] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + /// Describes a project participant. + public struct Participant { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// Participant's name, may be empty. + public var name: String = String() + + /// Participant's email, may be empty. + public var email: String = String() + + /// Participants identifier. + public var id: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + } + + public init() {} +} + +/// Top-level message sent by the client for the `Invite` method. +public struct Speechly_Config_V1_InviteRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// The ID of the project to invite to. + public var project: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// Top-level message sent by the server for the `Invite` method. +public struct Speechly_Config_V1_InviteResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// The token that can be used for joining the project. + /// The token is only valid once so if you need to invite multiple people, + /// you have to generated a token for each person. + public var invitationToken: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// Top-level message sent by the client for the `JoinProject` method. +public struct Speechly_Config_V1_JoinProjectRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// The invitation token to use for joining a project. + public var invitationToken: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// Top-level message sent by the server for the `JoinProject` method. +public struct Speechly_Config_V1_JoinProjectResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// Top-level message sent by the client for the `ListApps` method. +public struct Speechly_Config_V1_ListAppsRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// The ID of the project to list the apps in. + public var project: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// Top-level message sent by the server for the `ListApps` method. +public struct Speechly_Config_V1_ListAppsResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// A list of apps belonging to the project. + public var apps: [Speechly_Config_V1_App] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// Top-level message sent by the client for the `GetApp` method. +public struct Speechly_Config_V1_GetAppRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// The ID of the app to fetch. + public var appID: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// Top-level message sent by the server for the `GetApp` method. +public struct Speechly_Config_V1_GetAppResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// The app fetched with the ID. + public var app: Speechly_Config_V1_App { + get {return _app ?? Speechly_Config_V1_App()} + set {_app = newValue} + } + /// Returns true if `app` has been explicitly set. + public var hasApp: Bool {return self._app != nil} + /// Clears the value of `app`. Subsequent reads from it will return its default value. + public mutating func clearApp() {self._app = nil} + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _app: Speechly_Config_V1_App? = nil +} + +/// Top-level message sent by the client for the `CreateApp` method. +public struct Speechly_Config_V1_CreateAppRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// The ID of the project in which the app will be created. + public var project: String = String() + + /// The app information to use for creation. + public var app: Speechly_Config_V1_App { + get {return _app ?? Speechly_Config_V1_App()} + set {_app = newValue} + } + /// Returns true if `app` has been explicitly set. + public var hasApp: Bool {return self._app != nil} + /// Clears the value of `app`. Subsequent reads from it will return its default value. + public mutating func clearApp() {self._app = nil} + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _app: Speechly_Config_V1_App? = nil +} + +/// Top-level message sent by the server for the `CreateApp` method. +public struct Speechly_Config_V1_CreateAppResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// The app information that was stored in the API. + /// The difference between the app in the request and response is generated fields. + public var app: Speechly_Config_V1_App { + get {return _app ?? Speechly_Config_V1_App()} + set {_app = newValue} + } + /// Returns true if `app` has been explicitly set. + public var hasApp: Bool {return self._app != nil} + /// Clears the value of `app`. Subsequent reads from it will return its default value. + public mutating func clearApp() {self._app = nil} + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _app: Speechly_Config_V1_App? = nil +} + +/// Top-level message sent by the client for the `UpdateApp` method. +public struct Speechly_Config_V1_UpdateAppRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// The app information to use for the update. + public var app: Speechly_Config_V1_App { + get {return _app ?? Speechly_Config_V1_App()} + set {_app = newValue} + } + /// Returns true if `app` has been explicitly set. + public var hasApp: Bool {return self._app != nil} + /// Clears the value of `app`. Subsequent reads from it will return its default value. + public mutating func clearApp() {self._app = nil} + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _app: Speechly_Config_V1_App? = nil +} + +/// Top-level message sent by the server for the `UpdateApp` method. +public struct Speechly_Config_V1_UpdateAppResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// Top-level message sent by the client for the `DeleteApp` method. +public struct Speechly_Config_V1_DeleteAppRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// The ID of the app to delete. + public var appID: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// Top-level message sent by the server for the `DeleteApp` method. +public struct Speechly_Config_V1_DeleteAppResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// Top-level message sent by the server for the `UploadTrainingData` method. +public struct Speechly_Config_V1_UploadTrainingDataRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// The ID of the app to train. + public var appID: String = String() + + /// Training data payload. + public var dataChunk: Data = Data() + + /// Content type of the training data payload. + public var contentType: Speechly_Config_V1_UploadTrainingDataRequest.ContentType = .unspecified + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + /// Identifies the content type of training data payload. + public enum ContentType: SwiftProtobuf.Enum { + public typealias RawValue = Int + case unspecified // = 0 + + /// A YAML file that contains intents, entities, SAL script and metadata. + /// Refer to Speechly documentation (https://www.speechly.com/docs/) for the details on the format. + case yaml // = 1 + + /// A TAR archive file that contains the YAML file with training payload and supporting vocabulary files. + /// Refer to Speechly documentation (https://www.speechly.com/docs/) for the details on the format. + case tar // = 2 + case UNRECOGNIZED(Int) + + public init() { + self = .unspecified + } + + public init?(rawValue: Int) { + switch rawValue { + case 0: self = .unspecified + case 1: self = .yaml + case 2: self = .tar + default: self = .UNRECOGNIZED(rawValue) + } + } + + public var rawValue: Int { + switch self { + case .unspecified: return 0 + case .yaml: return 1 + case .tar: return 2 + case .UNRECOGNIZED(let i): return i + } + } + + } + + public init() {} +} + +#if swift(>=4.2) + +extension Speechly_Config_V1_UploadTrainingDataRequest.ContentType: CaseIterable { + // The compiler won't synthesize support with the UNRECOGNIZED case. + public static var allCases: [Speechly_Config_V1_UploadTrainingDataRequest.ContentType] = [ + .unspecified, + .yaml, + .tar, + ] +} + +#endif // swift(>=4.2) + +/// Top-level message sent by the server for the `UploadTrainingData` method. +public struct Speechly_Config_V1_UploadTrainingDataResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// Top-level message sent by the server for the `DownloadCurrentTrainingData` method. +public struct Speechly_Config_V1_DownloadCurrentTrainingDataRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// The ID of the app to fetch. + public var appID: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// Top-level message sent by the server for the `DownloadCurrentTrainingData` method. +public struct Speechly_Config_V1_DownloadCurrentTrainingDataResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// Training data payload. + public var dataChunk: Data = Data() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// Describes a Speechly application and is used as an argument for application API. +public struct Speechly_Config_V1_App { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// The ID of the application. + /// This field is ignored when creating an application. + public var id: String = String() + + /// The language of the application as a BCP-47 language tag (e.g. "en-US"). + /// Required. + public var language: String = String() + + /// The status of the application. + /// This field is ignored in requests. + public var status: Speechly_Config_V1_App.Status = .unspecified + + /// The human-friendly name of the application. + public var name: String = String() + + /// The size of the training queue size if the application is queued for training. + /// This field is ignored in requests. + public var queueSize: Int32 = 0 + + /// The detailed error description if the application failed training. + /// This field is ignored in requests. + public var errorMsg: String = String() + + /// Estimated training time remaining if the application is being trained. + /// Will equal to 0 when no estimate is available. + /// This field is ignored in requests. + public var estimatedRemainingSec: Int32 = 0 + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + /// The status of then application, defaults to STATUS_UNSPECIFIED. + public enum Status: SwiftProtobuf.Enum { + public typealias RawValue = Int + + /// Indicates that the application only been created, but never trained. + case unspecified // = 0 + + /// Indicates that the application is currently in the training queue. + case new // = 1 + + /// Indicates that the application is currently being trained. + case training // = 2 + + /// Indicates that the application has been successfully trained. + case trained // = 3 + + /// Indicates that the application has failed the training. + case failed // = 4 + case UNRECOGNIZED(Int) + + public init() { + self = .unspecified + } + + public init?(rawValue: Int) { + switch rawValue { + case 0: self = .unspecified + case 1: self = .new + case 2: self = .training + case 3: self = .trained + case 4: self = .failed + default: self = .UNRECOGNIZED(rawValue) + } + } + + public var rawValue: Int { + switch self { + case .unspecified: return 0 + case .new: return 1 + case .training: return 2 + case .trained: return 3 + case .failed: return 4 + case .UNRECOGNIZED(let i): return i + } + } + + } + + public init() {} +} + +#if swift(>=4.2) + +extension Speechly_Config_V1_App.Status: CaseIterable { + // The compiler won't synthesize support with the UNRECOGNIZED case. + public static var allCases: [Speechly_Config_V1_App.Status] = [ + .unspecified, + .new, + .training, + .trained, + .failed, + ] +} + +#endif // swift(>=4.2) + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +fileprivate let _protobuf_package = "speechly.config.v1" + +extension Speechly_Config_V1_GetProjectRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetProjectRequest" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap() + + public mutating func decodeMessage(decoder: inout D) throws { + while let _ = try decoder.nextFieldNumber() { + } + } + + public func traverse(visitor: inout V) throws { + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Speechly_Config_V1_GetProjectRequest, rhs: Speechly_Config_V1_GetProjectRequest) -> Bool { + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Speechly_Config_V1_GetProjectResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetProjectResponse" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "project"), + 2: .standard(proto: "project_names"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeRepeatedStringField(value: &self.project) }() + case 2: try { try decoder.decodeRepeatedStringField(value: &self.projectNames) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.project.isEmpty { + try visitor.visitRepeatedStringField(value: self.project, fieldNumber: 1) + } + if !self.projectNames.isEmpty { + try visitor.visitRepeatedStringField(value: self.projectNames, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Speechly_Config_V1_GetProjectResponse, rhs: Speechly_Config_V1_GetProjectResponse) -> Bool { + if lhs.project != rhs.project {return false} + if lhs.projectNames != rhs.projectNames {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Speechly_Config_V1_CreateProjectRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".CreateProjectRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "name"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.name) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.name.isEmpty { + try visitor.visitSingularStringField(value: self.name, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Speechly_Config_V1_CreateProjectRequest, rhs: Speechly_Config_V1_CreateProjectRequest) -> Bool { + if lhs.name != rhs.name {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Speechly_Config_V1_CreateProjectResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".CreateProjectResponse" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "project"), + 2: .same(proto: "name"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.project) }() + case 2: try { try decoder.decodeSingularStringField(value: &self.name) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.project.isEmpty { + try visitor.visitSingularStringField(value: self.project, fieldNumber: 1) + } + if !self.name.isEmpty { + try visitor.visitSingularStringField(value: self.name, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Speechly_Config_V1_CreateProjectResponse, rhs: Speechly_Config_V1_CreateProjectResponse) -> Bool { + if lhs.project != rhs.project {return false} + if lhs.name != rhs.name {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Speechly_Config_V1_UpdateProjectRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".UpdateProjectRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "project"), + 2: .same(proto: "name"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.project) }() + case 2: try { try decoder.decodeSingularStringField(value: &self.name) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.project.isEmpty { + try visitor.visitSingularStringField(value: self.project, fieldNumber: 1) + } + if !self.name.isEmpty { + try visitor.visitSingularStringField(value: self.name, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Speechly_Config_V1_UpdateProjectRequest, rhs: Speechly_Config_V1_UpdateProjectRequest) -> Bool { + if lhs.project != rhs.project {return false} + if lhs.name != rhs.name {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Speechly_Config_V1_UpdateProjectResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".UpdateProjectResponse" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap() + + public mutating func decodeMessage(decoder: inout D) throws { + while let _ = try decoder.nextFieldNumber() { + } + } + + public func traverse(visitor: inout V) throws { + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Speechly_Config_V1_UpdateProjectResponse, rhs: Speechly_Config_V1_UpdateProjectResponse) -> Bool { + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Speechly_Config_V1_GetProjectParticipantsRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetProjectParticipantsRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "project"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.project) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.project.isEmpty { + try visitor.visitSingularStringField(value: self.project, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Speechly_Config_V1_GetProjectParticipantsRequest, rhs: Speechly_Config_V1_GetProjectParticipantsRequest) -> Bool { + if lhs.project != rhs.project {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Speechly_Config_V1_GetProjectParticipantsResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetProjectParticipantsResponse" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "participants"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeRepeatedMessageField(value: &self.participants) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.participants.isEmpty { + try visitor.visitRepeatedMessageField(value: self.participants, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Speechly_Config_V1_GetProjectParticipantsResponse, rhs: Speechly_Config_V1_GetProjectParticipantsResponse) -> Bool { + if lhs.participants != rhs.participants {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Speechly_Config_V1_GetProjectParticipantsResponse.Participant: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = Speechly_Config_V1_GetProjectParticipantsResponse.protoMessageName + ".Participant" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "name"), + 2: .same(proto: "email"), + 3: .same(proto: "id"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.name) }() + case 2: try { try decoder.decodeSingularStringField(value: &self.email) }() + case 3: try { try decoder.decodeSingularStringField(value: &self.id) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.name.isEmpty { + try visitor.visitSingularStringField(value: self.name, fieldNumber: 1) + } + if !self.email.isEmpty { + try visitor.visitSingularStringField(value: self.email, fieldNumber: 2) + } + if !self.id.isEmpty { + try visitor.visitSingularStringField(value: self.id, fieldNumber: 3) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Speechly_Config_V1_GetProjectParticipantsResponse.Participant, rhs: Speechly_Config_V1_GetProjectParticipantsResponse.Participant) -> Bool { + if lhs.name != rhs.name {return false} + if lhs.email != rhs.email {return false} + if lhs.id != rhs.id {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Speechly_Config_V1_InviteRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".InviteRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "project"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.project) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.project.isEmpty { + try visitor.visitSingularStringField(value: self.project, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Speechly_Config_V1_InviteRequest, rhs: Speechly_Config_V1_InviteRequest) -> Bool { + if lhs.project != rhs.project {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Speechly_Config_V1_InviteResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".InviteResponse" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "invitation_token"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.invitationToken) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.invitationToken.isEmpty { + try visitor.visitSingularStringField(value: self.invitationToken, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Speechly_Config_V1_InviteResponse, rhs: Speechly_Config_V1_InviteResponse) -> Bool { + if lhs.invitationToken != rhs.invitationToken {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Speechly_Config_V1_JoinProjectRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".JoinProjectRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "invitation_token"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.invitationToken) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.invitationToken.isEmpty { + try visitor.visitSingularStringField(value: self.invitationToken, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Speechly_Config_V1_JoinProjectRequest, rhs: Speechly_Config_V1_JoinProjectRequest) -> Bool { + if lhs.invitationToken != rhs.invitationToken {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Speechly_Config_V1_JoinProjectResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".JoinProjectResponse" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap() + + public mutating func decodeMessage(decoder: inout D) throws { + while let _ = try decoder.nextFieldNumber() { + } + } + + public func traverse(visitor: inout V) throws { + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Speechly_Config_V1_JoinProjectResponse, rhs: Speechly_Config_V1_JoinProjectResponse) -> Bool { + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Speechly_Config_V1_ListAppsRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".ListAppsRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "project"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.project) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.project.isEmpty { + try visitor.visitSingularStringField(value: self.project, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Speechly_Config_V1_ListAppsRequest, rhs: Speechly_Config_V1_ListAppsRequest) -> Bool { + if lhs.project != rhs.project {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Speechly_Config_V1_ListAppsResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".ListAppsResponse" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "apps"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeRepeatedMessageField(value: &self.apps) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.apps.isEmpty { + try visitor.visitRepeatedMessageField(value: self.apps, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Speechly_Config_V1_ListAppsResponse, rhs: Speechly_Config_V1_ListAppsResponse) -> Bool { + if lhs.apps != rhs.apps {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Speechly_Config_V1_GetAppRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetAppRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "app_id"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.appID) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.appID.isEmpty { + try visitor.visitSingularStringField(value: self.appID, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Speechly_Config_V1_GetAppRequest, rhs: Speechly_Config_V1_GetAppRequest) -> Bool { + if lhs.appID != rhs.appID {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Speechly_Config_V1_GetAppResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetAppResponse" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "app"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularMessageField(value: &self._app) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if let v = self._app { + try visitor.visitSingularMessageField(value: v, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Speechly_Config_V1_GetAppResponse, rhs: Speechly_Config_V1_GetAppResponse) -> Bool { + if lhs._app != rhs._app {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Speechly_Config_V1_CreateAppRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".CreateAppRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "project"), + 2: .same(proto: "app"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.project) }() + case 2: try { try decoder.decodeSingularMessageField(value: &self._app) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.project.isEmpty { + try visitor.visitSingularStringField(value: self.project, fieldNumber: 1) + } + if let v = self._app { + try visitor.visitSingularMessageField(value: v, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Speechly_Config_V1_CreateAppRequest, rhs: Speechly_Config_V1_CreateAppRequest) -> Bool { + if lhs.project != rhs.project {return false} + if lhs._app != rhs._app {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Speechly_Config_V1_CreateAppResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".CreateAppResponse" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "app"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularMessageField(value: &self._app) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if let v = self._app { + try visitor.visitSingularMessageField(value: v, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Speechly_Config_V1_CreateAppResponse, rhs: Speechly_Config_V1_CreateAppResponse) -> Bool { + if lhs._app != rhs._app {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Speechly_Config_V1_UpdateAppRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".UpdateAppRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "app"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularMessageField(value: &self._app) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if let v = self._app { + try visitor.visitSingularMessageField(value: v, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Speechly_Config_V1_UpdateAppRequest, rhs: Speechly_Config_V1_UpdateAppRequest) -> Bool { + if lhs._app != rhs._app {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Speechly_Config_V1_UpdateAppResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".UpdateAppResponse" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap() + + public mutating func decodeMessage(decoder: inout D) throws { + while let _ = try decoder.nextFieldNumber() { + } + } + + public func traverse(visitor: inout V) throws { + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Speechly_Config_V1_UpdateAppResponse, rhs: Speechly_Config_V1_UpdateAppResponse) -> Bool { + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Speechly_Config_V1_DeleteAppRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".DeleteAppRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "app_id"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.appID) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.appID.isEmpty { + try visitor.visitSingularStringField(value: self.appID, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Speechly_Config_V1_DeleteAppRequest, rhs: Speechly_Config_V1_DeleteAppRequest) -> Bool { + if lhs.appID != rhs.appID {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Speechly_Config_V1_DeleteAppResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".DeleteAppResponse" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap() + + public mutating func decodeMessage(decoder: inout D) throws { + while let _ = try decoder.nextFieldNumber() { + } + } + + public func traverse(visitor: inout V) throws { + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Speechly_Config_V1_DeleteAppResponse, rhs: Speechly_Config_V1_DeleteAppResponse) -> Bool { + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Speechly_Config_V1_UploadTrainingDataRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".UploadTrainingDataRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "app_id"), + 2: .standard(proto: "data_chunk"), + 3: .standard(proto: "content_type"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.appID) }() + case 2: try { try decoder.decodeSingularBytesField(value: &self.dataChunk) }() + case 3: try { try decoder.decodeSingularEnumField(value: &self.contentType) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.appID.isEmpty { + try visitor.visitSingularStringField(value: self.appID, fieldNumber: 1) + } + if !self.dataChunk.isEmpty { + try visitor.visitSingularBytesField(value: self.dataChunk, fieldNumber: 2) + } + if self.contentType != .unspecified { + try visitor.visitSingularEnumField(value: self.contentType, fieldNumber: 3) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Speechly_Config_V1_UploadTrainingDataRequest, rhs: Speechly_Config_V1_UploadTrainingDataRequest) -> Bool { + if lhs.appID != rhs.appID {return false} + if lhs.dataChunk != rhs.dataChunk {return false} + if lhs.contentType != rhs.contentType {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Speechly_Config_V1_UploadTrainingDataRequest.ContentType: SwiftProtobuf._ProtoNameProviding { + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 0: .same(proto: "CONTENT_TYPE_UNSPECIFIED"), + 1: .same(proto: "CONTENT_TYPE_YAML"), + 2: .same(proto: "CONTENT_TYPE_TAR"), + ] +} + +extension Speechly_Config_V1_UploadTrainingDataResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".UploadTrainingDataResponse" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap() + + public mutating func decodeMessage(decoder: inout D) throws { + while let _ = try decoder.nextFieldNumber() { + } + } + + public func traverse(visitor: inout V) throws { + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Speechly_Config_V1_UploadTrainingDataResponse, rhs: Speechly_Config_V1_UploadTrainingDataResponse) -> Bool { + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Speechly_Config_V1_DownloadCurrentTrainingDataRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".DownloadCurrentTrainingDataRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "app_id"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.appID) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.appID.isEmpty { + try visitor.visitSingularStringField(value: self.appID, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Speechly_Config_V1_DownloadCurrentTrainingDataRequest, rhs: Speechly_Config_V1_DownloadCurrentTrainingDataRequest) -> Bool { + if lhs.appID != rhs.appID {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Speechly_Config_V1_DownloadCurrentTrainingDataResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".DownloadCurrentTrainingDataResponse" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "data_chunk"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.dataChunk) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.dataChunk.isEmpty { + try visitor.visitSingularBytesField(value: self.dataChunk, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Speechly_Config_V1_DownloadCurrentTrainingDataResponse, rhs: Speechly_Config_V1_DownloadCurrentTrainingDataResponse) -> Bool { + if lhs.dataChunk != rhs.dataChunk {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Speechly_Config_V1_App: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".App" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "id"), + 2: .same(proto: "language"), + 3: .same(proto: "status"), + 4: .same(proto: "name"), + 5: .standard(proto: "queue_size"), + 6: .standard(proto: "error_msg"), + 7: .standard(proto: "estimated_remaining_sec"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.id) }() + case 2: try { try decoder.decodeSingularStringField(value: &self.language) }() + case 3: try { try decoder.decodeSingularEnumField(value: &self.status) }() + case 4: try { try decoder.decodeSingularStringField(value: &self.name) }() + case 5: try { try decoder.decodeSingularInt32Field(value: &self.queueSize) }() + case 6: try { try decoder.decodeSingularStringField(value: &self.errorMsg) }() + case 7: try { try decoder.decodeSingularInt32Field(value: &self.estimatedRemainingSec) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.id.isEmpty { + try visitor.visitSingularStringField(value: self.id, fieldNumber: 1) + } + if !self.language.isEmpty { + try visitor.visitSingularStringField(value: self.language, fieldNumber: 2) + } + if self.status != .unspecified { + try visitor.visitSingularEnumField(value: self.status, fieldNumber: 3) + } + if !self.name.isEmpty { + try visitor.visitSingularStringField(value: self.name, fieldNumber: 4) + } + if self.queueSize != 0 { + try visitor.visitSingularInt32Field(value: self.queueSize, fieldNumber: 5) + } + if !self.errorMsg.isEmpty { + try visitor.visitSingularStringField(value: self.errorMsg, fieldNumber: 6) + } + if self.estimatedRemainingSec != 0 { + try visitor.visitSingularInt32Field(value: self.estimatedRemainingSec, fieldNumber: 7) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Speechly_Config_V1_App, rhs: Speechly_Config_V1_App) -> Bool { + if lhs.id != rhs.id {return false} + if lhs.language != rhs.language {return false} + if lhs.status != rhs.status {return false} + if lhs.name != rhs.name {return false} + if lhs.queueSize != rhs.queueSize {return false} + if lhs.errorMsg != rhs.errorMsg {return false} + if lhs.estimatedRemainingSec != rhs.estimatedRemainingSec {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Speechly_Config_V1_App.Status: SwiftProtobuf._ProtoNameProviding { + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 0: .same(proto: "STATUS_UNSPECIFIED"), + 1: .same(proto: "STATUS_NEW"), + 2: .same(proto: "STATUS_TRAINING"), + 3: .same(proto: "STATUS_TRAINED"), + 4: .same(proto: "STATUS_FAILED"), + ] +} diff --git a/Sources/SpeechlyAPI/speechly/identity/v1/identity.grpc.swift b/Sources/SpeechlyAPI/speechly/identity/v1/identity.grpc.swift new file mode 100644 index 0000000..bffe7fc --- /dev/null +++ b/Sources/SpeechlyAPI/speechly/identity/v1/identity.grpc.swift @@ -0,0 +1,98 @@ +// +// DO NOT EDIT. +// +// Generated by the protocol buffer compiler. +// Source: speechly/identity/v1/identity.proto +// + +// +// Copyright 2018, gRPC Authors All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +import GRPC +import NIO +import SwiftProtobuf + + +/// Usage: instantiate Speechly_Identity_V1_IdentityClient, then call methods of this protocol to make API calls. +public protocol Speechly_Identity_V1_IdentityClientProtocol: GRPCClient { + func login( + _ request: Speechly_Identity_V1_LoginRequest, + callOptions: CallOptions? + ) -> UnaryCall + +} + +extension Speechly_Identity_V1_IdentityClientProtocol { + + /// Performs a login of specific Speechly application. + /// Returns an access token, that can be used to access Speechly SLU API. + /// + /// - Parameters: + /// - request: Request to send to Login. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func login( + _ request: Speechly_Identity_V1_LoginRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return self.makeUnaryCall( + path: "/speechly.identity.v1.Identity/Login", + request: request, + callOptions: callOptions ?? self.defaultCallOptions + ) + } +} + +public final class Speechly_Identity_V1_IdentityClient: Speechly_Identity_V1_IdentityClientProtocol { + public let channel: GRPCChannel + public var defaultCallOptions: CallOptions + + /// Creates a client for the speechly.identity.v1.Identity service. + /// + /// - Parameters: + /// - channel: `GRPCChannel` to the service host. + /// - defaultCallOptions: Options to use for each service call if the user doesn't provide them. + public init(channel: GRPCChannel, defaultCallOptions: CallOptions = CallOptions()) { + self.channel = channel + self.defaultCallOptions = defaultCallOptions + } +} + +/// To build a server, implement a class that conforms to this protocol. +public protocol Speechly_Identity_V1_IdentityProvider: CallHandlerProvider { + /// Performs a login of specific Speechly application. + /// Returns an access token, that can be used to access Speechly SLU API. + func login(request: Speechly_Identity_V1_LoginRequest, context: StatusOnlyCallContext) -> EventLoopFuture +} + +extension Speechly_Identity_V1_IdentityProvider { + public var serviceName: Substring { return "speechly.identity.v1.Identity" } + + /// Determines, calls and returns the appropriate request handler, depending on the request's method. + /// Returns nil for methods not handled by this service. + public func handleMethod(_ methodName: Substring, callHandlerContext: CallHandlerContext) -> GRPCCallHandler? { + switch methodName { + case "Login": + return CallHandlerFactory.makeUnary(callHandlerContext: callHandlerContext) { context in + return { request in + self.login(request: request, context: context) + } + } + + default: return nil + } + } +} + diff --git a/Sources/SpeechlyAPI/speechly/identity/v1/identity.pb.swift b/Sources/SpeechlyAPI/speechly/identity/v1/identity.pb.swift new file mode 100644 index 0000000..0db58e5 --- /dev/null +++ b/Sources/SpeechlyAPI/speechly/identity/v1/identity.pb.swift @@ -0,0 +1,131 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: speechly/identity/v1/identity.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +import Foundation +import SwiftProtobuf + +// If the compiler emits an error on this type, it is because this file +// was generated by a version of the `protoc` Swift plug-in that is +// incompatible with the version of SwiftProtobuf to which you are linking. +// Please ensure that you are building against the same version of the API +// that was used to generate this file. +fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 +} + +/// Top-level message sent by the client for the `Login` method. +public struct Speechly_Identity_V1_LoginRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// A unique end-user device identifier. + /// Required. + public var deviceID: String = String() + + /// Speechly application ID. + /// Required. + public var appID: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// Top-level message sent by the server for the `Login` method. +public struct Speechly_Identity_V1_LoginResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// Access token which can used for Speechly SLU API. + /// The token is a JSON Web Token and includes all standard claims, as well as custom ones. + /// The token has expiration, so you should check whether it has expired before using it. + /// It is safe to cache the token for future use until its expiration date. + public var token: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +fileprivate let _protobuf_package = "speechly.identity.v1" + +extension Speechly_Identity_V1_LoginRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".LoginRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "device_id"), + 2: .standard(proto: "app_id"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.deviceID) }() + case 2: try { try decoder.decodeSingularStringField(value: &self.appID) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.deviceID.isEmpty { + try visitor.visitSingularStringField(value: self.deviceID, fieldNumber: 1) + } + if !self.appID.isEmpty { + try visitor.visitSingularStringField(value: self.appID, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Speechly_Identity_V1_LoginRequest, rhs: Speechly_Identity_V1_LoginRequest) -> Bool { + if lhs.deviceID != rhs.deviceID {return false} + if lhs.appID != rhs.appID {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Speechly_Identity_V1_LoginResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".LoginResponse" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "token"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.token) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.token.isEmpty { + try visitor.visitSingularStringField(value: self.token, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Speechly_Identity_V1_LoginResponse, rhs: Speechly_Identity_V1_LoginResponse) -> Bool { + if lhs.token != rhs.token {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} diff --git a/Sources/SpeechlyAPI/speechly/sal/v1/compiler.grpc.swift b/Sources/SpeechlyAPI/speechly/sal/v1/compiler.grpc.swift new file mode 100644 index 0000000..e4d7bbe --- /dev/null +++ b/Sources/SpeechlyAPI/speechly/sal/v1/compiler.grpc.swift @@ -0,0 +1,121 @@ +// +// DO NOT EDIT. +// +// Generated by the protocol buffer compiler. +// Source: speechly/sal/v1/compiler.proto +// + +// +// Copyright 2018, gRPC Authors All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +import GRPC +import NIO +import SwiftProtobuf + + +/// Usage: instantiate Speechly_Sal_V1_CompilerClient, then call methods of this protocol to make API calls. +public protocol Speechly_Sal_V1_CompilerClientProtocol: GRPCClient { + func compile( + callOptions: CallOptions? + ) -> ClientStreamingCall + + func validate( + callOptions: CallOptions? + ) -> ClientStreamingCall + +} + +extension Speechly_Sal_V1_CompilerClientProtocol { + + /// Compiles the SAL source and returns compiled templates and / or any compilation errors and warnings. + /// + /// Callers should use the `send` method on the returned object to send messages + /// to the server. The caller should send an `.end` after the final message has been sent. + /// + /// - Parameters: + /// - callOptions: Call options. + /// - Returns: A `ClientStreamingCall` with futures for the metadata, status and response. + public func compile( + callOptions: CallOptions? = nil + ) -> ClientStreamingCall { + return self.makeClientStreamingCall( + path: "/speechly.sal.v1.Compiler/Compile", + callOptions: callOptions ?? self.defaultCallOptions + ) + } + + /// Validates the SAL source and returns compilation notices / warnings and errors, if any. + /// + /// Callers should use the `send` method on the returned object to send messages + /// to the server. The caller should send an `.end` after the final message has been sent. + /// + /// - Parameters: + /// - callOptions: Call options. + /// - Returns: A `ClientStreamingCall` with futures for the metadata, status and response. + public func validate( + callOptions: CallOptions? = nil + ) -> ClientStreamingCall { + return self.makeClientStreamingCall( + path: "/speechly.sal.v1.Compiler/Validate", + callOptions: callOptions ?? self.defaultCallOptions + ) + } +} + +public final class Speechly_Sal_V1_CompilerClient: Speechly_Sal_V1_CompilerClientProtocol { + public let channel: GRPCChannel + public var defaultCallOptions: CallOptions + + /// Creates a client for the speechly.sal.v1.Compiler service. + /// + /// - Parameters: + /// - channel: `GRPCChannel` to the service host. + /// - defaultCallOptions: Options to use for each service call if the user doesn't provide them. + public init(channel: GRPCChannel, defaultCallOptions: CallOptions = CallOptions()) { + self.channel = channel + self.defaultCallOptions = defaultCallOptions + } +} + +/// To build a server, implement a class that conforms to this protocol. +public protocol Speechly_Sal_V1_CompilerProvider: CallHandlerProvider { + /// Compiles the SAL source and returns compiled templates and / or any compilation errors and warnings. + func compile(context: UnaryResponseCallContext) -> EventLoopFuture<(StreamEvent) -> Void> + /// Validates the SAL source and returns compilation notices / warnings and errors, if any. + func validate(context: UnaryResponseCallContext) -> EventLoopFuture<(StreamEvent) -> Void> +} + +extension Speechly_Sal_V1_CompilerProvider { + public var serviceName: Substring { return "speechly.sal.v1.Compiler" } + + /// Determines, calls and returns the appropriate request handler, depending on the request's method. + /// Returns nil for methods not handled by this service. + public func handleMethod(_ methodName: Substring, callHandlerContext: CallHandlerContext) -> GRPCCallHandler? { + switch methodName { + case "Compile": + return CallHandlerFactory.makeClientStreaming(callHandlerContext: callHandlerContext) { context in + return self.compile(context: context) + } + + case "Validate": + return CallHandlerFactory.makeClientStreaming(callHandlerContext: callHandlerContext) { context in + return self.validate(context: context) + } + + default: return nil + } + } +} + diff --git a/Sources/SpeechlyAPI/speechly/sal/v1/compiler.pb.swift b/Sources/SpeechlyAPI/speechly/sal/v1/compiler.pb.swift new file mode 100644 index 0000000..3278a9d --- /dev/null +++ b/Sources/SpeechlyAPI/speechly/sal/v1/compiler.pb.swift @@ -0,0 +1,400 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: speechly/sal/v1/compiler.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +import Foundation +import SwiftProtobuf + +// If the compiler emits an error on this type, it is because this file +// was generated by a version of the `protoc` Swift plug-in that is +// incompatible with the version of SwiftProtobuf to which you are linking. +// Please ensure that you are building against the same version of the API +// that was used to generate this file. +fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 +} + +/// Contains a chunk of SAL source. +/// This message is consumed by `Compile` and `Validate` RPCs. +public struct Speechly_Sal_V1_AppSource { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// The ID of Speechly app to compile for. + public var appID: String = String() + + /// The language of SAL as a BCP-47 language tag (e.g. "en-US"). + public var language: String = String() + + /// Chunk of SAL source code. + public var dataChunk: Data = Data() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// Top-level message sent by the server for the `Compile` method. +public struct Speechly_Sal_V1_CompileResult { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// The status of compilation. + public var result: Speechly_Sal_V1_CompileResult.Result = .compileSuccess + + /// (If the result was compiled) A list of compiled templates. + public var templates: [String] = [] + + /// (If the result failed or had warnings) A list of error / warning messages. + public var messages: [Speechly_Sal_V1_LineReference] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + /// Describes the status of result. + public enum Result: SwiftProtobuf.Enum { + public typealias RawValue = Int + + /// Result has been successfully compiled. + case compileSuccess // = 0 + + /// Result has failed to compile. + case compileFailure // = 1 + + /// Result has been compiled, but with warnings. + case compileWarning // = 2 + case UNRECOGNIZED(Int) + + public init() { + self = .compileSuccess + } + + public init?(rawValue: Int) { + switch rawValue { + case 0: self = .compileSuccess + case 1: self = .compileFailure + case 2: self = .compileWarning + default: self = .UNRECOGNIZED(rawValue) + } + } + + public var rawValue: Int { + switch self { + case .compileSuccess: return 0 + case .compileFailure: return 1 + case .compileWarning: return 2 + case .UNRECOGNIZED(let i): return i + } + } + + } + + public init() {} +} + +#if swift(>=4.2) + +extension Speechly_Sal_V1_CompileResult.Result: CaseIterable { + // The compiler won't synthesize support with the UNRECOGNIZED case. + public static var allCases: [Speechly_Sal_V1_CompileResult.Result] = [ + .compileSuccess, + .compileFailure, + .compileWarning, + ] +} + +#endif // swift(>=4.2) + +/// Top-level message sent by the server for the `Validate` method. +public struct Speechly_Sal_V1_ValidateResult { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// A list of error / warning messages, may be empty if validation didn't find any issues. + public var messages: [Speechly_Sal_V1_LineReference] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// Describes a message related to a line in SAL source code. +public struct Speechly_Sal_V1_LineReference { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// The line in SAL source that this message refers to. + public var line: UInt64 = 0 + + /// The column in SAL source that this message refers to. + public var column: UInt32 = 0 + + /// The file in SAL sources that this message refers to. + public var file: String = String() + + /// The level of the message. + public var level: Speechly_Sal_V1_LineReference.Level = .note + + /// The contents of the message. + public var message: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + /// The level of the message. + public enum Level: SwiftProtobuf.Enum { + public typealias RawValue = Int + + /// A notice - for information only. + case note // = 0 + + /// A warning, does not fail compilation or validation, but should be addressed. + case warning // = 1 + + /// An error, fails compilation and validation. + case error // = 2 + case UNRECOGNIZED(Int) + + public init() { + self = .note + } + + public init?(rawValue: Int) { + switch rawValue { + case 0: self = .note + case 1: self = .warning + case 2: self = .error + default: self = .UNRECOGNIZED(rawValue) + } + } + + public var rawValue: Int { + switch self { + case .note: return 0 + case .warning: return 1 + case .error: return 2 + case .UNRECOGNIZED(let i): return i + } + } + + } + + public init() {} +} + +#if swift(>=4.2) + +extension Speechly_Sal_V1_LineReference.Level: CaseIterable { + // The compiler won't synthesize support with the UNRECOGNIZED case. + public static var allCases: [Speechly_Sal_V1_LineReference.Level] = [ + .note, + .warning, + .error, + ] +} + +#endif // swift(>=4.2) + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +fileprivate let _protobuf_package = "speechly.sal.v1" + +extension Speechly_Sal_V1_AppSource: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".AppSource" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "app_id"), + 2: .same(proto: "language"), + 3: .standard(proto: "data_chunk"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.appID) }() + case 2: try { try decoder.decodeSingularStringField(value: &self.language) }() + case 3: try { try decoder.decodeSingularBytesField(value: &self.dataChunk) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.appID.isEmpty { + try visitor.visitSingularStringField(value: self.appID, fieldNumber: 1) + } + if !self.language.isEmpty { + try visitor.visitSingularStringField(value: self.language, fieldNumber: 2) + } + if !self.dataChunk.isEmpty { + try visitor.visitSingularBytesField(value: self.dataChunk, fieldNumber: 3) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Speechly_Sal_V1_AppSource, rhs: Speechly_Sal_V1_AppSource) -> Bool { + if lhs.appID != rhs.appID {return false} + if lhs.language != rhs.language {return false} + if lhs.dataChunk != rhs.dataChunk {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Speechly_Sal_V1_CompileResult: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".CompileResult" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "result"), + 2: .same(proto: "templates"), + 3: .same(proto: "messages"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularEnumField(value: &self.result) }() + case 2: try { try decoder.decodeRepeatedStringField(value: &self.templates) }() + case 3: try { try decoder.decodeRepeatedMessageField(value: &self.messages) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if self.result != .compileSuccess { + try visitor.visitSingularEnumField(value: self.result, fieldNumber: 1) + } + if !self.templates.isEmpty { + try visitor.visitRepeatedStringField(value: self.templates, fieldNumber: 2) + } + if !self.messages.isEmpty { + try visitor.visitRepeatedMessageField(value: self.messages, fieldNumber: 3) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Speechly_Sal_V1_CompileResult, rhs: Speechly_Sal_V1_CompileResult) -> Bool { + if lhs.result != rhs.result {return false} + if lhs.templates != rhs.templates {return false} + if lhs.messages != rhs.messages {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Speechly_Sal_V1_CompileResult.Result: SwiftProtobuf._ProtoNameProviding { + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 0: .same(proto: "COMPILE_SUCCESS"), + 1: .same(proto: "COMPILE_FAILURE"), + 2: .same(proto: "COMPILE_WARNING"), + ] +} + +extension Speechly_Sal_V1_ValidateResult: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".ValidateResult" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "messages"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeRepeatedMessageField(value: &self.messages) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.messages.isEmpty { + try visitor.visitRepeatedMessageField(value: self.messages, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Speechly_Sal_V1_ValidateResult, rhs: Speechly_Sal_V1_ValidateResult) -> Bool { + if lhs.messages != rhs.messages {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Speechly_Sal_V1_LineReference: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".LineReference" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "line"), + 2: .same(proto: "column"), + 3: .same(proto: "file"), + 4: .same(proto: "level"), + 5: .same(proto: "message"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularUInt64Field(value: &self.line) }() + case 2: try { try decoder.decodeSingularUInt32Field(value: &self.column) }() + case 3: try { try decoder.decodeSingularStringField(value: &self.file) }() + case 4: try { try decoder.decodeSingularEnumField(value: &self.level) }() + case 5: try { try decoder.decodeSingularStringField(value: &self.message) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if self.line != 0 { + try visitor.visitSingularUInt64Field(value: self.line, fieldNumber: 1) + } + if self.column != 0 { + try visitor.visitSingularUInt32Field(value: self.column, fieldNumber: 2) + } + if !self.file.isEmpty { + try visitor.visitSingularStringField(value: self.file, fieldNumber: 3) + } + if self.level != .note { + try visitor.visitSingularEnumField(value: self.level, fieldNumber: 4) + } + if !self.message.isEmpty { + try visitor.visitSingularStringField(value: self.message, fieldNumber: 5) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Speechly_Sal_V1_LineReference, rhs: Speechly_Sal_V1_LineReference) -> Bool { + if lhs.line != rhs.line {return false} + if lhs.column != rhs.column {return false} + if lhs.file != rhs.file {return false} + if lhs.level != rhs.level {return false} + if lhs.message != rhs.message {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Speechly_Sal_V1_LineReference.Level: SwiftProtobuf._ProtoNameProviding { + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 0: .same(proto: "LEVEL_NOTE"), + 1: .same(proto: "LEVEL_WARNING"), + 2: .same(proto: "LEVEL_ERROR"), + ] +} diff --git a/Sources/SpeechlyAPI/speechly/slu/v1/slu.grpc.swift b/Sources/SpeechlyAPI/speechly/slu/v1/slu.grpc.swift new file mode 100644 index 0000000..9383bf7 --- /dev/null +++ b/Sources/SpeechlyAPI/speechly/slu/v1/slu.grpc.swift @@ -0,0 +1,139 @@ +// +// DO NOT EDIT. +// +// Generated by the protocol buffer compiler. +// Source: speechly/slu/v1/slu.proto +// + +// +// Copyright 2018, gRPC Authors All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +import GRPC +import NIO +import SwiftProtobuf + + +/// Usage: instantiate Speechly_Slu_V1_SLUClient, then call methods of this protocol to make API calls. +public protocol Speechly_Slu_V1_SLUClientProtocol: GRPCClient { + func stream( + callOptions: CallOptions?, + handler: @escaping (Speechly_Slu_V1_SLUResponse) -> Void + ) -> BidirectionalStreamingCall + +} + +extension Speechly_Slu_V1_SLUClientProtocol { + + /// Performs bidirectional streaming speech recognition: receive results while sending audio. + /// + /// First request MUST be an SLUConfig message with the configuration that describes the audio format being sent. + /// + /// This RPC can handle multiple logical audio segments with the use of SLUEvent_START and SLUEvent_STOP messages, + /// which are used to indicate the beginning and the end of a segment. + /// + /// A typical call timeline will look like this: + /// + /// 1. Client starts the RPC. + /// 2. Client sends SLUConfig message with audio configuration. + /// 3. Client sends SLUEvent_START. + /// 4. Client sends audio and receives responses from the server. + /// 5. Client sends SLUEvent_STOP. + /// 6. Client sends SLUEvent_START. + /// 7. Client sends audio and receives responses from the server. + /// 8. Client sends SLUEvent_STOP. + /// 9. Client closes the stream and receives responses from the server until EOF is received. + /// + /// NB: the client does not have to wait until the server acknowledges the start / stop events, + /// this is done asynchronously. The client can deduplicate responses based on the audio context ID, + /// which will be present in every response message. + /// + /// Callers should use the `send` method on the returned object to send messages + /// to the server. The caller should send an `.end` after the final message has been sent. + /// + /// - Parameters: + /// - callOptions: Call options. + /// - handler: A closure called when each response is received from the server. + /// - Returns: A `ClientStreamingCall` with futures for the metadata and status. + public func stream( + callOptions: CallOptions? = nil, + handler: @escaping (Speechly_Slu_V1_SLUResponse) -> Void + ) -> BidirectionalStreamingCall { + return self.makeBidirectionalStreamingCall( + path: "/speechly.slu.v1.SLU/Stream", + callOptions: callOptions ?? self.defaultCallOptions, + handler: handler + ) + } +} + +public final class Speechly_Slu_V1_SLUClient: Speechly_Slu_V1_SLUClientProtocol { + public let channel: GRPCChannel + public var defaultCallOptions: CallOptions + + /// Creates a client for the speechly.slu.v1.SLU service. + /// + /// - Parameters: + /// - channel: `GRPCChannel` to the service host. + /// - defaultCallOptions: Options to use for each service call if the user doesn't provide them. + public init(channel: GRPCChannel, defaultCallOptions: CallOptions = CallOptions()) { + self.channel = channel + self.defaultCallOptions = defaultCallOptions + } +} + +/// To build a server, implement a class that conforms to this protocol. +public protocol Speechly_Slu_V1_SLUProvider: CallHandlerProvider { + /// Performs bidirectional streaming speech recognition: receive results while sending audio. + /// + /// First request MUST be an SLUConfig message with the configuration that describes the audio format being sent. + /// + /// This RPC can handle multiple logical audio segments with the use of SLUEvent_START and SLUEvent_STOP messages, + /// which are used to indicate the beginning and the end of a segment. + /// + /// A typical call timeline will look like this: + /// + /// 1. Client starts the RPC. + /// 2. Client sends SLUConfig message with audio configuration. + /// 3. Client sends SLUEvent_START. + /// 4. Client sends audio and receives responses from the server. + /// 5. Client sends SLUEvent_STOP. + /// 6. Client sends SLUEvent_START. + /// 7. Client sends audio and receives responses from the server. + /// 8. Client sends SLUEvent_STOP. + /// 9. Client closes the stream and receives responses from the server until EOF is received. + /// + /// NB: the client does not have to wait until the server acknowledges the start / stop events, + /// this is done asynchronously. The client can deduplicate responses based on the audio context ID, + /// which will be present in every response message. + func stream(context: StreamingResponseCallContext) -> EventLoopFuture<(StreamEvent) -> Void> +} + +extension Speechly_Slu_V1_SLUProvider { + public var serviceName: Substring { return "speechly.slu.v1.SLU" } + + /// Determines, calls and returns the appropriate request handler, depending on the request's method. + /// Returns nil for methods not handled by this service. + public func handleMethod(_ methodName: Substring, callHandlerContext: CallHandlerContext) -> GRPCCallHandler? { + switch methodName { + case "Stream": + return CallHandlerFactory.makeBidirectionalStreaming(callHandlerContext: callHandlerContext) { context in + return self.stream(context: context) + } + + default: return nil + } + } +} + diff --git a/Sources/SpeechlyAPI/speechly/slu/v1/slu.pb.swift b/Sources/SpeechlyAPI/speechly/slu/v1/slu.pb.swift new file mode 100644 index 0000000..3c1eed5 --- /dev/null +++ b/Sources/SpeechlyAPI/speechly/slu/v1/slu.pb.swift @@ -0,0 +1,1250 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: speechly/slu/v1/slu.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +import Foundation +import SwiftProtobuf + +// If the compiler emits an error on this type, it is because this file +// was generated by a version of the `protoc` Swift plug-in that is +// incompatible with the version of SwiftProtobuf to which you are linking. +// Please ensure that you are building against the same version of the API +// that was used to generate this file. +fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 +} + +/// Top-level message sent by the client for the `Stream` method. +public struct Speechly_Slu_V1_SLURequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var streamingRequest: Speechly_Slu_V1_SLURequest.OneOf_StreamingRequest? = nil + + /// Describes the configuration of the audio sent by the client. + /// MUST be the first message sent to the stream. + public var config: Speechly_Slu_V1_SLUConfig { + get { + if case .config(let v)? = streamingRequest {return v} + return Speechly_Slu_V1_SLUConfig() + } + set {streamingRequest = .config(newValue)} + } + + /// Indicates the beginning and the end of a logical audio segment (audio context in Speechly terms). + /// A context MUST be preceded by a start event and concluded with a stop event, + /// otherwise the server WILL terminate the stream with an error. + public var event: Speechly_Slu_V1_SLUEvent { + get { + if case .event(let v)? = streamingRequest {return v} + return Speechly_Slu_V1_SLUEvent() + } + set {streamingRequest = .event(newValue)} + } + + /// Contains a chunk of the audio being streamed. + public var audio: Data { + get { + if case .audio(let v)? = streamingRequest {return v} + return Data() + } + set {streamingRequest = .audio(newValue)} + } + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public enum OneOf_StreamingRequest: Equatable { + /// Describes the configuration of the audio sent by the client. + /// MUST be the first message sent to the stream. + case config(Speechly_Slu_V1_SLUConfig) + /// Indicates the beginning and the end of a logical audio segment (audio context in Speechly terms). + /// A context MUST be preceded by a start event and concluded with a stop event, + /// otherwise the server WILL terminate the stream with an error. + case event(Speechly_Slu_V1_SLUEvent) + /// Contains a chunk of the audio being streamed. + case audio(Data) + + #if !swift(>=4.1) + public static func ==(lhs: Speechly_Slu_V1_SLURequest.OneOf_StreamingRequest, rhs: Speechly_Slu_V1_SLURequest.OneOf_StreamingRequest) -> Bool { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch (lhs, rhs) { + case (.config, .config): return { + guard case .config(let l) = lhs, case .config(let r) = rhs else { preconditionFailure() } + return l == r + }() + case (.event, .event): return { + guard case .event(let l) = lhs, case .event(let r) = rhs else { preconditionFailure() } + return l == r + }() + case (.audio, .audio): return { + guard case .audio(let l) = lhs, case .audio(let r) = rhs else { preconditionFailure() } + return l == r + }() + default: return false + } + } + #endif + } + + public init() {} +} + +/// Describes the configuration of the audio sent by the client. +/// Currently the API only supports single-channel Linear PCM with sample rate of 16 kHz. +public struct Speechly_Slu_V1_SLUConfig { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// The encoding of the audio data sent in the stream. + /// Required. + public var encoding: Speechly_Slu_V1_SLUConfig.Encoding = .linear16 + + /// The number of channels in the input audio data. + /// Required. + public var channels: Int32 = 0 + + /// Sample rate in Hertz of the audio data sent in the stream. + /// Required. + public var sampleRateHertz: Int32 = 0 + + /// The language of the audio sent in the stream as a BCP-47 language tag (e.g. "en-US"). + /// Required. + public var languageCode: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + /// The encoding of the audio data sent in the stream. + public enum Encoding: SwiftProtobuf.Enum { + public typealias RawValue = Int + + /// Uncompressed 16-bit signed little-endian samples (Linear PCM). + case linear16 // = 0 + case UNRECOGNIZED(Int) + + public init() { + self = .linear16 + } + + public init?(rawValue: Int) { + switch rawValue { + case 0: self = .linear16 + default: self = .UNRECOGNIZED(rawValue) + } + } + + public var rawValue: Int { + switch self { + case .linear16: return 0 + case .UNRECOGNIZED(let i): return i + } + } + + } + + public init() {} +} + +#if swift(>=4.2) + +extension Speechly_Slu_V1_SLUConfig.Encoding: CaseIterable { + // The compiler won't synthesize support with the UNRECOGNIZED case. + public static var allCases: [Speechly_Slu_V1_SLUConfig.Encoding] = [ + .linear16, + ] +} + +#endif // swift(>=4.2) + +/// Indicates the beginning and the end of a logical audio segment (audio context in Speechly terms). +public struct Speechly_Slu_V1_SLUEvent { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// The event type being sent. Required. + public var event: Speechly_Slu_V1_SLUEvent.Event = .start + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + /// The event type value. + public enum Event: SwiftProtobuf.Enum { + public typealias RawValue = Int + + /// START indicates the beginning of the audio context. Must be sent before sending audio data. + case start // = 0 + + /// STOP indicates the end of the audio context. Must be sent after sending last chunk of audio in that segment. + case stop // = 1 + case UNRECOGNIZED(Int) + + public init() { + self = .start + } + + public init?(rawValue: Int) { + switch rawValue { + case 0: self = .start + case 1: self = .stop + default: self = .UNRECOGNIZED(rawValue) + } + } + + public var rawValue: Int { + switch self { + case .start: return 0 + case .stop: return 1 + case .UNRECOGNIZED(let i): return i + } + } + + } + + public init() {} +} + +#if swift(>=4.2) + +extension Speechly_Slu_V1_SLUEvent.Event: CaseIterable { + // The compiler won't synthesize support with the UNRECOGNIZED case. + public static var allCases: [Speechly_Slu_V1_SLUEvent.Event] = [ + .start, + .stop, + ] +} + +#endif // swift(>=4.2) + +/// Top-level message sent by the server for the `Stream` method. +public struct Speechly_Slu_V1_SLUResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// The ID of the audio context that this response belongs to. + public var audioContext: String = String() + + /// The ID of the SLU segment that this response belongs to. + /// This will be 0 for SLUStarted and SLUFinished responses. + public var segmentID: Int32 = 0 + + /// Response payload. + public var streamingResponse: Speechly_Slu_V1_SLUResponse.OneOf_StreamingResponse? = nil + + /// Final SLU transcript. + public var transcript: Speechly_Slu_V1_SLUTranscript { + get { + if case .transcript(let v)? = streamingResponse {return v} + return Speechly_Slu_V1_SLUTranscript() + } + set {streamingResponse = .transcript(newValue)} + } + + /// Final SLU entity. + public var entity: Speechly_Slu_V1_SLUEntity { + get { + if case .entity(let v)? = streamingResponse {return v} + return Speechly_Slu_V1_SLUEntity() + } + set {streamingResponse = .entity(newValue)} + } + + /// Final SLU intent. + public var intent: Speechly_Slu_V1_SLUIntent { + get { + if case .intent(let v)? = streamingResponse {return v} + return Speechly_Slu_V1_SLUIntent() + } + set {streamingResponse = .intent(newValue)} + } + + /// A special marker message that indicates that the segment with specified `segment_id` + /// has been finalised and no new responses belonging to that segment will be sent. + /// The client is expected to discard any tentative responses in this segment. + public var segmentEnd: Speechly_Slu_V1_SLUSegmentEnd { + get { + if case .segmentEnd(let v)? = streamingResponse {return v} + return Speechly_Slu_V1_SLUSegmentEnd() + } + set {streamingResponse = .segmentEnd(newValue)} + } + + /// Tentative SLU transcript. + public var tentativeTranscript: Speechly_Slu_V1_SLUTentativeTranscript { + get { + if case .tentativeTranscript(let v)? = streamingResponse {return v} + return Speechly_Slu_V1_SLUTentativeTranscript() + } + set {streamingResponse = .tentativeTranscript(newValue)} + } + + /// Tentative SLU entities. + public var tentativeEntities: Speechly_Slu_V1_SLUTentativeEntities { + get { + if case .tentativeEntities(let v)? = streamingResponse {return v} + return Speechly_Slu_V1_SLUTentativeEntities() + } + set {streamingResponse = .tentativeEntities(newValue)} + } + + /// Tentative SLU intent. + public var tentativeIntent: Speechly_Slu_V1_SLUIntent { + get { + if case .tentativeIntent(let v)? = streamingResponse {return v} + return Speechly_Slu_V1_SLUIntent() + } + set {streamingResponse = .tentativeIntent(newValue)} + } + + /// A special marker message that indicates that the audio context with specified `audio_context` id + /// has been started by the API and all audio data sent by the client will be processed in that context. + /// This message is an asynchronous acknowledgement for client-side SLUEvent_START message. + public var started: Speechly_Slu_V1_SLUStarted { + get { + if case .started(let v)? = streamingResponse {return v} + return Speechly_Slu_V1_SLUStarted() + } + set {streamingResponse = .started(newValue)} + } + + /// A special marker message that indicates that the audio context with specified `audio_context` id + /// has been stopped by the API and no new responses for that context will be sent. + /// The client is expected to discard any non-finalised segments. + /// This message is an asynchronous acknowledgement for client-side SLUEvent_STOP message. + public var finished: Speechly_Slu_V1_SLUFinished { + get { + if case .finished(let v)? = streamingResponse {return v} + return Speechly_Slu_V1_SLUFinished() + } + set {streamingResponse = .finished(newValue)} + } + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + /// Response payload. + public enum OneOf_StreamingResponse: Equatable { + /// Final SLU transcript. + case transcript(Speechly_Slu_V1_SLUTranscript) + /// Final SLU entity. + case entity(Speechly_Slu_V1_SLUEntity) + /// Final SLU intent. + case intent(Speechly_Slu_V1_SLUIntent) + /// A special marker message that indicates that the segment with specified `segment_id` + /// has been finalised and no new responses belonging to that segment will be sent. + /// The client is expected to discard any tentative responses in this segment. + case segmentEnd(Speechly_Slu_V1_SLUSegmentEnd) + /// Tentative SLU transcript. + case tentativeTranscript(Speechly_Slu_V1_SLUTentativeTranscript) + /// Tentative SLU entities. + case tentativeEntities(Speechly_Slu_V1_SLUTentativeEntities) + /// Tentative SLU intent. + case tentativeIntent(Speechly_Slu_V1_SLUIntent) + /// A special marker message that indicates that the audio context with specified `audio_context` id + /// has been started by the API and all audio data sent by the client will be processed in that context. + /// This message is an asynchronous acknowledgement for client-side SLUEvent_START message. + case started(Speechly_Slu_V1_SLUStarted) + /// A special marker message that indicates that the audio context with specified `audio_context` id + /// has been stopped by the API and no new responses for that context will be sent. + /// The client is expected to discard any non-finalised segments. + /// This message is an asynchronous acknowledgement for client-side SLUEvent_STOP message. + case finished(Speechly_Slu_V1_SLUFinished) + + #if !swift(>=4.1) + public static func ==(lhs: Speechly_Slu_V1_SLUResponse.OneOf_StreamingResponse, rhs: Speechly_Slu_V1_SLUResponse.OneOf_StreamingResponse) -> Bool { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch (lhs, rhs) { + case (.transcript, .transcript): return { + guard case .transcript(let l) = lhs, case .transcript(let r) = rhs else { preconditionFailure() } + return l == r + }() + case (.entity, .entity): return { + guard case .entity(let l) = lhs, case .entity(let r) = rhs else { preconditionFailure() } + return l == r + }() + case (.intent, .intent): return { + guard case .intent(let l) = lhs, case .intent(let r) = rhs else { preconditionFailure() } + return l == r + }() + case (.segmentEnd, .segmentEnd): return { + guard case .segmentEnd(let l) = lhs, case .segmentEnd(let r) = rhs else { preconditionFailure() } + return l == r + }() + case (.tentativeTranscript, .tentativeTranscript): return { + guard case .tentativeTranscript(let l) = lhs, case .tentativeTranscript(let r) = rhs else { preconditionFailure() } + return l == r + }() + case (.tentativeEntities, .tentativeEntities): return { + guard case .tentativeEntities(let l) = lhs, case .tentativeEntities(let r) = rhs else { preconditionFailure() } + return l == r + }() + case (.tentativeIntent, .tentativeIntent): return { + guard case .tentativeIntent(let l) = lhs, case .tentativeIntent(let r) = rhs else { preconditionFailure() } + return l == r + }() + case (.started, .started): return { + guard case .started(let l) = lhs, case .started(let r) = rhs else { preconditionFailure() } + return l == r + }() + case (.finished, .finished): return { + guard case .finished(let l) = lhs, case .finished(let r) = rhs else { preconditionFailure() } + return l == r + }() + default: return false + } + } + #endif + } + + public init() {} +} + +/// Describes an SLU transcript. +/// A transcript is a speech-to-text element of the phrase, i.e. a word recognised from the audio. +public struct Speechly_Slu_V1_SLUTranscript { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// The word recongised from the audio. + public var word: String = String() + + /// The position of the word in the whole phrase, zero-based. + public var index: Int32 = 0 + + /// The end time of the word in the audio, in milliseconds from the beginning of the audio. + public var startTime: Int32 = 0 + + /// The end time of the word in the audio, in milliseconds from the beginning of the audio. + public var endTime: Int32 = 0 + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// Describes an SLU entity. +/// +/// An entity is a specific object in the phrase that falls into some kind of category, +/// e.g. in a SAL example "*book book a [burger restaurant](restaurant_type) for [tomorrow](date)" +/// "burger restaurant" would be an entity of type `restaurant_type`, +/// and "tomorrow" would be an entity of type `date`. +/// +/// An entity has a start and end indices which map to the indices of words in SLUTranscript messages, +/// e.g. in the example "book a [burger restaurant](restaurant_type) for [tomorrow](date)" it would be: +/// +/// * Entity "burger restaurant" - `start_position = 2, end_position = 3` +/// * Entity "tomorrow" - `start_position = 5, end_position = 5` +/// +/// The start index is inclusive, but the end index is exclusive, i.e. the interval is `[start_position, end_position)`. +public struct Speechly_Slu_V1_SLUEntity { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// The type of the entity, e.g. `restaurant_type` or `date`. + public var entity: String = String() + + /// The value of the entity, e.g. `burger restaurant` or `tomorrow`. + public var value: String = String() + + /// The starting index of the entity in the phrase, maps to the `index` field in `SLUTranscript`. + /// Inclusive. + public var startPosition: Int32 = 0 + + /// The finishing index of the entity in the phrase, maps to the `index` field in `SLUTranscript`. + /// Exclusive. + public var endPosition: Int32 = 0 + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// Describes an SLU intent. +/// There can be only one intent per SLU segment. +public struct Speechly_Slu_V1_SLUIntent { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// The value of the intent, as defined in SAL. + public var intent: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// Indicates the end of the segment. +/// Upon receiving this, the segment should be finalised and all future messages for that segment (if any) discarded. +public struct Speechly_Slu_V1_SLUSegmentEnd { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// Describes a tentative transcript. +/// +/// Tentative transcript is an interim recognition result, which may change over time, +/// e.g. a phrase "find me a red t-shirt" can be tentatively recognised as "find me a tea", +/// until the API processes the audio completely. +public struct Speechly_Slu_V1_SLUTentativeTranscript { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// Aggregated tentative transcript from the beginning of the audio until current moment in time. + /// Consecutive transcripts will have this value appended to, + /// e.g. if in the first message it's "find me", in the next it may be "find me a t-shirt". + public var tentativeTranscript: String = String() + + /// A list of individual words which compose `tentative_transcript`. + /// All words must be considered tentative. + public var tentativeWords: [Speechly_Slu_V1_SLUTranscript] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// Describes tentative entities. +public struct Speechly_Slu_V1_SLUTentativeEntities { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// A list of entities, which must be treated as tentative. + /// + /// This is not an aggregate of all entities in the audio, + /// but rather it ONLY contains entities that have not been finalised yet. + /// + /// e.g. if at the start there are two tentatively recognised entities - ["burger restaurant", "tomorrow"] + /// but then the API marks "burger restaurant" as final and recognises a new tentative entity "for two", + /// this will contain ["tomorrow", "for two"]. + public var tentativeEntities: [Speechly_Slu_V1_SLUEntity] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// Indicates that the API has started processing the portion of audio as new audio context. +/// This does not guarantee that the server will not send any more messages for the previous audio context. +public struct Speechly_Slu_V1_SLUStarted { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// Indicates that the API has stopped processing current audio context. +/// It guarantees that no new messages for that context will be sent by the server. +public struct Speechly_Slu_V1_SLUFinished { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// DEPRECATED + /// An error which has happened when processing the context, if any. + public var error: Speechly_Slu_V1_SLUError { + get {return _error ?? Speechly_Slu_V1_SLUError()} + set {_error = newValue} + } + /// Returns true if `error` has been explicitly set. + public var hasError: Bool {return self._error != nil} + /// Clears the value of `error`. Subsequent reads from it will return its default value. + public mutating func clearError() {self._error = nil} + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _error: Speechly_Slu_V1_SLUError? = nil +} + +/// Describes the error that happened when processing an audio context. +public struct Speechly_Slu_V1_SLUError { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// Error code (refer to documentation for specific codes). + public var code: String = String() + + /// Error message. + public var message: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +fileprivate let _protobuf_package = "speechly.slu.v1" + +extension Speechly_Slu_V1_SLURequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".SLURequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "config"), + 2: .same(proto: "event"), + 3: .same(proto: "audio"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { + var v: Speechly_Slu_V1_SLUConfig? + if let current = self.streamingRequest { + try decoder.handleConflictingOneOf() + if case .config(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v {self.streamingRequest = .config(v)} + }() + case 2: try { + var v: Speechly_Slu_V1_SLUEvent? + if let current = self.streamingRequest { + try decoder.handleConflictingOneOf() + if case .event(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v {self.streamingRequest = .event(v)} + }() + case 3: try { + if self.streamingRequest != nil {try decoder.handleConflictingOneOf()} + var v: Data? + try decoder.decodeSingularBytesField(value: &v) + if let v = v {self.streamingRequest = .audio(v)} + }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch self.streamingRequest { + case .config?: try { + guard case .config(let v)? = self.streamingRequest else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 1) + }() + case .event?: try { + guard case .event(let v)? = self.streamingRequest else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 2) + }() + case .audio?: try { + guard case .audio(let v)? = self.streamingRequest else { preconditionFailure() } + try visitor.visitSingularBytesField(value: v, fieldNumber: 3) + }() + case nil: break + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Speechly_Slu_V1_SLURequest, rhs: Speechly_Slu_V1_SLURequest) -> Bool { + if lhs.streamingRequest != rhs.streamingRequest {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Speechly_Slu_V1_SLUConfig: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".SLUConfig" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "encoding"), + 2: .same(proto: "channels"), + 3: .standard(proto: "sample_rate_hertz"), + 4: .standard(proto: "language_code"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularEnumField(value: &self.encoding) }() + case 2: try { try decoder.decodeSingularInt32Field(value: &self.channels) }() + case 3: try { try decoder.decodeSingularInt32Field(value: &self.sampleRateHertz) }() + case 4: try { try decoder.decodeSingularStringField(value: &self.languageCode) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if self.encoding != .linear16 { + try visitor.visitSingularEnumField(value: self.encoding, fieldNumber: 1) + } + if self.channels != 0 { + try visitor.visitSingularInt32Field(value: self.channels, fieldNumber: 2) + } + if self.sampleRateHertz != 0 { + try visitor.visitSingularInt32Field(value: self.sampleRateHertz, fieldNumber: 3) + } + if !self.languageCode.isEmpty { + try visitor.visitSingularStringField(value: self.languageCode, fieldNumber: 4) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Speechly_Slu_V1_SLUConfig, rhs: Speechly_Slu_V1_SLUConfig) -> Bool { + if lhs.encoding != rhs.encoding {return false} + if lhs.channels != rhs.channels {return false} + if lhs.sampleRateHertz != rhs.sampleRateHertz {return false} + if lhs.languageCode != rhs.languageCode {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Speechly_Slu_V1_SLUConfig.Encoding: SwiftProtobuf._ProtoNameProviding { + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 0: .same(proto: "LINEAR16"), + ] +} + +extension Speechly_Slu_V1_SLUEvent: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".SLUEvent" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "event"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularEnumField(value: &self.event) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if self.event != .start { + try visitor.visitSingularEnumField(value: self.event, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Speechly_Slu_V1_SLUEvent, rhs: Speechly_Slu_V1_SLUEvent) -> Bool { + if lhs.event != rhs.event {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Speechly_Slu_V1_SLUEvent.Event: SwiftProtobuf._ProtoNameProviding { + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 0: .same(proto: "START"), + 1: .same(proto: "STOP"), + ] +} + +extension Speechly_Slu_V1_SLUResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".SLUResponse" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "audio_context"), + 2: .standard(proto: "segment_id"), + 3: .same(proto: "transcript"), + 4: .same(proto: "entity"), + 5: .same(proto: "intent"), + 6: .standard(proto: "segment_end"), + 7: .standard(proto: "tentative_transcript"), + 8: .standard(proto: "tentative_entities"), + 9: .standard(proto: "tentative_intent"), + 10: .same(proto: "started"), + 11: .same(proto: "finished"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.audioContext) }() + case 2: try { try decoder.decodeSingularInt32Field(value: &self.segmentID) }() + case 3: try { + var v: Speechly_Slu_V1_SLUTranscript? + if let current = self.streamingResponse { + try decoder.handleConflictingOneOf() + if case .transcript(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v {self.streamingResponse = .transcript(v)} + }() + case 4: try { + var v: Speechly_Slu_V1_SLUEntity? + if let current = self.streamingResponse { + try decoder.handleConflictingOneOf() + if case .entity(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v {self.streamingResponse = .entity(v)} + }() + case 5: try { + var v: Speechly_Slu_V1_SLUIntent? + if let current = self.streamingResponse { + try decoder.handleConflictingOneOf() + if case .intent(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v {self.streamingResponse = .intent(v)} + }() + case 6: try { + var v: Speechly_Slu_V1_SLUSegmentEnd? + if let current = self.streamingResponse { + try decoder.handleConflictingOneOf() + if case .segmentEnd(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v {self.streamingResponse = .segmentEnd(v)} + }() + case 7: try { + var v: Speechly_Slu_V1_SLUTentativeTranscript? + if let current = self.streamingResponse { + try decoder.handleConflictingOneOf() + if case .tentativeTranscript(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v {self.streamingResponse = .tentativeTranscript(v)} + }() + case 8: try { + var v: Speechly_Slu_V1_SLUTentativeEntities? + if let current = self.streamingResponse { + try decoder.handleConflictingOneOf() + if case .tentativeEntities(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v {self.streamingResponse = .tentativeEntities(v)} + }() + case 9: try { + var v: Speechly_Slu_V1_SLUIntent? + if let current = self.streamingResponse { + try decoder.handleConflictingOneOf() + if case .tentativeIntent(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v {self.streamingResponse = .tentativeIntent(v)} + }() + case 10: try { + var v: Speechly_Slu_V1_SLUStarted? + if let current = self.streamingResponse { + try decoder.handleConflictingOneOf() + if case .started(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v {self.streamingResponse = .started(v)} + }() + case 11: try { + var v: Speechly_Slu_V1_SLUFinished? + if let current = self.streamingResponse { + try decoder.handleConflictingOneOf() + if case .finished(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v {self.streamingResponse = .finished(v)} + }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.audioContext.isEmpty { + try visitor.visitSingularStringField(value: self.audioContext, fieldNumber: 1) + } + if self.segmentID != 0 { + try visitor.visitSingularInt32Field(value: self.segmentID, fieldNumber: 2) + } + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch self.streamingResponse { + case .transcript?: try { + guard case .transcript(let v)? = self.streamingResponse else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 3) + }() + case .entity?: try { + guard case .entity(let v)? = self.streamingResponse else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 4) + }() + case .intent?: try { + guard case .intent(let v)? = self.streamingResponse else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 5) + }() + case .segmentEnd?: try { + guard case .segmentEnd(let v)? = self.streamingResponse else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 6) + }() + case .tentativeTranscript?: try { + guard case .tentativeTranscript(let v)? = self.streamingResponse else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 7) + }() + case .tentativeEntities?: try { + guard case .tentativeEntities(let v)? = self.streamingResponse else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 8) + }() + case .tentativeIntent?: try { + guard case .tentativeIntent(let v)? = self.streamingResponse else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 9) + }() + case .started?: try { + guard case .started(let v)? = self.streamingResponse else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 10) + }() + case .finished?: try { + guard case .finished(let v)? = self.streamingResponse else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 11) + }() + case nil: break + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Speechly_Slu_V1_SLUResponse, rhs: Speechly_Slu_V1_SLUResponse) -> Bool { + if lhs.audioContext != rhs.audioContext {return false} + if lhs.segmentID != rhs.segmentID {return false} + if lhs.streamingResponse != rhs.streamingResponse {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Speechly_Slu_V1_SLUTranscript: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".SLUTranscript" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "word"), + 2: .same(proto: "index"), + 3: .standard(proto: "start_time"), + 4: .standard(proto: "end_time"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.word) }() + case 2: try { try decoder.decodeSingularInt32Field(value: &self.index) }() + case 3: try { try decoder.decodeSingularInt32Field(value: &self.startTime) }() + case 4: try { try decoder.decodeSingularInt32Field(value: &self.endTime) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.word.isEmpty { + try visitor.visitSingularStringField(value: self.word, fieldNumber: 1) + } + if self.index != 0 { + try visitor.visitSingularInt32Field(value: self.index, fieldNumber: 2) + } + if self.startTime != 0 { + try visitor.visitSingularInt32Field(value: self.startTime, fieldNumber: 3) + } + if self.endTime != 0 { + try visitor.visitSingularInt32Field(value: self.endTime, fieldNumber: 4) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Speechly_Slu_V1_SLUTranscript, rhs: Speechly_Slu_V1_SLUTranscript) -> Bool { + if lhs.word != rhs.word {return false} + if lhs.index != rhs.index {return false} + if lhs.startTime != rhs.startTime {return false} + if lhs.endTime != rhs.endTime {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Speechly_Slu_V1_SLUEntity: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".SLUEntity" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "entity"), + 2: .same(proto: "value"), + 3: .standard(proto: "start_position"), + 4: .standard(proto: "end_position"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.entity) }() + case 2: try { try decoder.decodeSingularStringField(value: &self.value) }() + case 3: try { try decoder.decodeSingularInt32Field(value: &self.startPosition) }() + case 4: try { try decoder.decodeSingularInt32Field(value: &self.endPosition) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.entity.isEmpty { + try visitor.visitSingularStringField(value: self.entity, fieldNumber: 1) + } + if !self.value.isEmpty { + try visitor.visitSingularStringField(value: self.value, fieldNumber: 2) + } + if self.startPosition != 0 { + try visitor.visitSingularInt32Field(value: self.startPosition, fieldNumber: 3) + } + if self.endPosition != 0 { + try visitor.visitSingularInt32Field(value: self.endPosition, fieldNumber: 4) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Speechly_Slu_V1_SLUEntity, rhs: Speechly_Slu_V1_SLUEntity) -> Bool { + if lhs.entity != rhs.entity {return false} + if lhs.value != rhs.value {return false} + if lhs.startPosition != rhs.startPosition {return false} + if lhs.endPosition != rhs.endPosition {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Speechly_Slu_V1_SLUIntent: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".SLUIntent" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "intent"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.intent) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.intent.isEmpty { + try visitor.visitSingularStringField(value: self.intent, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Speechly_Slu_V1_SLUIntent, rhs: Speechly_Slu_V1_SLUIntent) -> Bool { + if lhs.intent != rhs.intent {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Speechly_Slu_V1_SLUSegmentEnd: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".SLUSegmentEnd" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap() + + public mutating func decodeMessage(decoder: inout D) throws { + while let _ = try decoder.nextFieldNumber() { + } + } + + public func traverse(visitor: inout V) throws { + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Speechly_Slu_V1_SLUSegmentEnd, rhs: Speechly_Slu_V1_SLUSegmentEnd) -> Bool { + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Speechly_Slu_V1_SLUTentativeTranscript: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".SLUTentativeTranscript" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "tentative_transcript"), + 2: .standard(proto: "tentative_words"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.tentativeTranscript) }() + case 2: try { try decoder.decodeRepeatedMessageField(value: &self.tentativeWords) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.tentativeTranscript.isEmpty { + try visitor.visitSingularStringField(value: self.tentativeTranscript, fieldNumber: 1) + } + if !self.tentativeWords.isEmpty { + try visitor.visitRepeatedMessageField(value: self.tentativeWords, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Speechly_Slu_V1_SLUTentativeTranscript, rhs: Speechly_Slu_V1_SLUTentativeTranscript) -> Bool { + if lhs.tentativeTranscript != rhs.tentativeTranscript {return false} + if lhs.tentativeWords != rhs.tentativeWords {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Speechly_Slu_V1_SLUTentativeEntities: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".SLUTentativeEntities" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "tentative_entities"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeRepeatedMessageField(value: &self.tentativeEntities) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.tentativeEntities.isEmpty { + try visitor.visitRepeatedMessageField(value: self.tentativeEntities, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Speechly_Slu_V1_SLUTentativeEntities, rhs: Speechly_Slu_V1_SLUTentativeEntities) -> Bool { + if lhs.tentativeEntities != rhs.tentativeEntities {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Speechly_Slu_V1_SLUStarted: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".SLUStarted" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap() + + public mutating func decodeMessage(decoder: inout D) throws { + while let _ = try decoder.nextFieldNumber() { + } + } + + public func traverse(visitor: inout V) throws { + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Speechly_Slu_V1_SLUStarted, rhs: Speechly_Slu_V1_SLUStarted) -> Bool { + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Speechly_Slu_V1_SLUFinished: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".SLUFinished" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 2: .same(proto: "error"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 2: try { try decoder.decodeSingularMessageField(value: &self._error) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if let v = self._error { + try visitor.visitSingularMessageField(value: v, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Speechly_Slu_V1_SLUFinished, rhs: Speechly_Slu_V1_SLUFinished) -> Bool { + if lhs._error != rhs._error {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Speechly_Slu_V1_SLUError: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".SLUError" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "code"), + 2: .same(proto: "message"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.code) }() + case 2: try { try decoder.decodeSingularStringField(value: &self.message) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.code.isEmpty { + try visitor.visitSingularStringField(value: self.code, fieldNumber: 1) + } + if !self.message.isEmpty { + try visitor.visitSingularStringField(value: self.message, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Speechly_Slu_V1_SLUError, rhs: Speechly_Slu_V1_SLUError) -> Bool { + if lhs.code != rhs.code {return false} + if lhs.message != rhs.message {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} diff --git a/Sources/SpeechlyAPI/speechly/slu/v1/wlu.grpc.swift b/Sources/SpeechlyAPI/speechly/slu/v1/wlu.grpc.swift new file mode 100644 index 0000000..5dccd13 --- /dev/null +++ b/Sources/SpeechlyAPI/speechly/slu/v1/wlu.grpc.swift @@ -0,0 +1,96 @@ +// +// DO NOT EDIT. +// +// Generated by the protocol buffer compiler. +// Source: speechly/slu/v1/wlu.proto +// + +// +// Copyright 2018, gRPC Authors All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +import GRPC +import NIO +import SwiftProtobuf + + +/// Usage: instantiate Speechly_Slu_V1_WLUClient, then call methods of this protocol to make API calls. +public protocol Speechly_Slu_V1_WLUClientProtocol: GRPCClient { + func text( + _ request: Speechly_Slu_V1_WLURequest, + callOptions: CallOptions? + ) -> UnaryCall + +} + +extension Speechly_Slu_V1_WLUClientProtocol { + + /// Performs recognition of a text with specified language. + /// + /// - Parameters: + /// - request: Request to send to Text. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func text( + _ request: Speechly_Slu_V1_WLURequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return self.makeUnaryCall( + path: "/speechly.slu.v1.WLU/Text", + request: request, + callOptions: callOptions ?? self.defaultCallOptions + ) + } +} + +public final class Speechly_Slu_V1_WLUClient: Speechly_Slu_V1_WLUClientProtocol { + public let channel: GRPCChannel + public var defaultCallOptions: CallOptions + + /// Creates a client for the speechly.slu.v1.WLU service. + /// + /// - Parameters: + /// - channel: `GRPCChannel` to the service host. + /// - defaultCallOptions: Options to use for each service call if the user doesn't provide them. + public init(channel: GRPCChannel, defaultCallOptions: CallOptions = CallOptions()) { + self.channel = channel + self.defaultCallOptions = defaultCallOptions + } +} + +/// To build a server, implement a class that conforms to this protocol. +public protocol Speechly_Slu_V1_WLUProvider: CallHandlerProvider { + /// Performs recognition of a text with specified language. + func text(request: Speechly_Slu_V1_WLURequest, context: StatusOnlyCallContext) -> EventLoopFuture +} + +extension Speechly_Slu_V1_WLUProvider { + public var serviceName: Substring { return "speechly.slu.v1.WLU" } + + /// Determines, calls and returns the appropriate request handler, depending on the request's method. + /// Returns nil for methods not handled by this service. + public func handleMethod(_ methodName: Substring, callHandlerContext: CallHandlerContext) -> GRPCCallHandler? { + switch methodName { + case "Text": + return CallHandlerFactory.makeUnary(callHandlerContext: callHandlerContext) { context in + return { request in + self.text(request: request, context: context) + } + } + + default: return nil + } + } +} + diff --git a/Sources/SpeechlyAPI/speechly/slu/v1/wlu.pb.swift b/Sources/SpeechlyAPI/speechly/slu/v1/wlu.pb.swift new file mode 100644 index 0000000..ae09176 --- /dev/null +++ b/Sources/SpeechlyAPI/speechly/slu/v1/wlu.pb.swift @@ -0,0 +1,403 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: speechly/slu/v1/wlu.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +import Foundation +import SwiftProtobuf + +// If the compiler emits an error on this type, it is because this file +// was generated by a version of the `protoc` Swift plug-in that is +// incompatible with the version of SwiftProtobuf to which you are linking. +// Please ensure that you are building against the same version of the API +// that was used to generate this file. +fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 +} + +/// Top-level message sent by the client for the `Text` method. +public struct Speechly_Slu_V1_WLURequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// The language of the text sent in the request as a BCP-47 language tag (e.g. "en-US"). + /// Required. + public var languageCode: String = String() + + /// The text to recognise. + /// Required. + public var text: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// Top-level message sent by the server for the `Text` method. +public struct Speechly_Slu_V1_WLUResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// A list of WLU segments. + public var segments: [Speechly_Slu_V1_WLUSegment] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// Describes a WLU segment. +/// A segment is a logical portion of text denoted by its intent, +/// e.g. in a phrase "book me a flight and rent a car" +/// there would be a segment for "book me a flight" and another for "rent a car". +public struct Speechly_Slu_V1_WLUSegment { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// The portion of text that contains this segment. + public var text: String = String() + + /// The list of word tokens which are contained in this segment. + public var tokens: [Speechly_Slu_V1_WLUToken] = [] + + /// The list of entities which are contained in this segment. + public var entities: [Speechly_Slu_V1_WLUEntity] = [] + + /// The intent that defines this segment. + public var intent: Speechly_Slu_V1_WLUIntent { + get {return _intent ?? Speechly_Slu_V1_WLUIntent()} + set {_intent = newValue} + } + /// Returns true if `intent` has been explicitly set. + public var hasIntent: Bool {return self._intent != nil} + /// Clears the value of `intent`. Subsequent reads from it will return its default value. + public mutating func clearIntent() {self._intent = nil} + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _intent: Speechly_Slu_V1_WLUIntent? = nil +} + +/// Describes a single word token in a segment. +public struct Speechly_Slu_V1_WLUToken { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// The value of the word. + public var word: String = String() + + /// Position of the token in the text. + public var index: Int32 = 0 + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// Describes a single entity in a segment. +/// +/// An entity is a specific object in the phrase that falls into some kind of category, +/// e.g. in a SAL example "*book book a [burger restaurant](restaurant_type) for [tomorrow](date)" +/// "burger restaurant" would be an entity of type `restaurant_type`, +/// and "tomorrow" would be an entity of type `date`. +/// +/// An entity has a start and end indices which map to the indices of words in WLUToken messages, +/// e.g. in the example "book a [burger restaurant](restaurant_type) for [tomorrow](date)" it would be: +/// +/// * Entity "burger restaurant" - `start_position = 2, end_position = 3` +/// * Entity "tomorrow" - `start_position = 5, end_position = 5` +/// +/// The start index is inclusive, but the end index is exclusive, i.e. the interval is `[start_position, end_position)`. +public struct Speechly_Slu_V1_WLUEntity { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// The type of the entity, e.g. `restaurant_type` or `date`. + public var entity: String = String() + + /// The value of the entity, e.g. `burger restaurant` or `tomorrow`. + public var value: String = String() + + /// The starting index of the entity in the phrase, maps to the `index` field in `SLUTranscript`. + /// Inclusive. + public var startPosition: Int32 = 0 + + /// The finishing index of the entity in the phrase, maps to the `index` field in `SLUTranscript`. + /// Exclusive. + public var endPosition: Int32 = 0 + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// Describes the intent of a segment. +/// There can only be one intent per segment. +public struct Speechly_Slu_V1_WLUIntent { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// The value of the intent, as defined in SAL. + public var intent: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +fileprivate let _protobuf_package = "speechly.slu.v1" + +extension Speechly_Slu_V1_WLURequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".WLURequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "language_code"), + 2: .same(proto: "text"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.languageCode) }() + case 2: try { try decoder.decodeSingularStringField(value: &self.text) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.languageCode.isEmpty { + try visitor.visitSingularStringField(value: self.languageCode, fieldNumber: 1) + } + if !self.text.isEmpty { + try visitor.visitSingularStringField(value: self.text, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Speechly_Slu_V1_WLURequest, rhs: Speechly_Slu_V1_WLURequest) -> Bool { + if lhs.languageCode != rhs.languageCode {return false} + if lhs.text != rhs.text {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Speechly_Slu_V1_WLUResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".WLUResponse" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "segments"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeRepeatedMessageField(value: &self.segments) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.segments.isEmpty { + try visitor.visitRepeatedMessageField(value: self.segments, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Speechly_Slu_V1_WLUResponse, rhs: Speechly_Slu_V1_WLUResponse) -> Bool { + if lhs.segments != rhs.segments {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Speechly_Slu_V1_WLUSegment: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".WLUSegment" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "text"), + 2: .same(proto: "tokens"), + 3: .same(proto: "entities"), + 4: .same(proto: "intent"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.text) }() + case 2: try { try decoder.decodeRepeatedMessageField(value: &self.tokens) }() + case 3: try { try decoder.decodeRepeatedMessageField(value: &self.entities) }() + case 4: try { try decoder.decodeSingularMessageField(value: &self._intent) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.text.isEmpty { + try visitor.visitSingularStringField(value: self.text, fieldNumber: 1) + } + if !self.tokens.isEmpty { + try visitor.visitRepeatedMessageField(value: self.tokens, fieldNumber: 2) + } + if !self.entities.isEmpty { + try visitor.visitRepeatedMessageField(value: self.entities, fieldNumber: 3) + } + if let v = self._intent { + try visitor.visitSingularMessageField(value: v, fieldNumber: 4) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Speechly_Slu_V1_WLUSegment, rhs: Speechly_Slu_V1_WLUSegment) -> Bool { + if lhs.text != rhs.text {return false} + if lhs.tokens != rhs.tokens {return false} + if lhs.entities != rhs.entities {return false} + if lhs._intent != rhs._intent {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Speechly_Slu_V1_WLUToken: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".WLUToken" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "word"), + 2: .same(proto: "index"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.word) }() + case 2: try { try decoder.decodeSingularInt32Field(value: &self.index) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.word.isEmpty { + try visitor.visitSingularStringField(value: self.word, fieldNumber: 1) + } + if self.index != 0 { + try visitor.visitSingularInt32Field(value: self.index, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Speechly_Slu_V1_WLUToken, rhs: Speechly_Slu_V1_WLUToken) -> Bool { + if lhs.word != rhs.word {return false} + if lhs.index != rhs.index {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Speechly_Slu_V1_WLUEntity: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".WLUEntity" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "entity"), + 2: .same(proto: "value"), + 3: .standard(proto: "start_position"), + 4: .standard(proto: "end_position"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.entity) }() + case 2: try { try decoder.decodeSingularStringField(value: &self.value) }() + case 3: try { try decoder.decodeSingularInt32Field(value: &self.startPosition) }() + case 4: try { try decoder.decodeSingularInt32Field(value: &self.endPosition) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.entity.isEmpty { + try visitor.visitSingularStringField(value: self.entity, fieldNumber: 1) + } + if !self.value.isEmpty { + try visitor.visitSingularStringField(value: self.value, fieldNumber: 2) + } + if self.startPosition != 0 { + try visitor.visitSingularInt32Field(value: self.startPosition, fieldNumber: 3) + } + if self.endPosition != 0 { + try visitor.visitSingularInt32Field(value: self.endPosition, fieldNumber: 4) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Speechly_Slu_V1_WLUEntity, rhs: Speechly_Slu_V1_WLUEntity) -> Bool { + if lhs.entity != rhs.entity {return false} + if lhs.value != rhs.value {return false} + if lhs.startPosition != rhs.startPosition {return false} + if lhs.endPosition != rhs.endPosition {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Speechly_Slu_V1_WLUIntent: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".WLUIntent" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "intent"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.intent) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.intent.isEmpty { + try visitor.visitSingularStringField(value: self.intent, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Speechly_Slu_V1_WLUIntent, rhs: Speechly_Slu_V1_WLUIntent) -> Bool { + if lhs.intent != rhs.intent {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +}