Skip to content

Commit

Permalink
feat(stt-tts): generation release changes
Browse files Browse the repository at this point in the history
  • Loading branch information
apaparazzi0329 committed May 11, 2021
1 parent d5da0a8 commit 7301a2f
Show file tree
Hide file tree
Showing 14 changed files with 1,194 additions and 94 deletions.
9 changes: 8 additions & 1 deletion Sources/SpeechToTextV1/Models/SupportedFeatures.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright IBM Corp. 2018, 2020.
* (C) Copyright IBM Corp. 2021.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -35,10 +35,17 @@ public struct SupportedFeatures: Codable, Equatable {
*/
public var speakerLabels: Bool

/**
Indicates whether the `low_latency` parameter can be used with a next-generation language model. The field is
returned only for next-generation models. Previous-generation models do not support the `low_latency` parameter.
*/
public var lowLatency: Bool?

// Map each property name to the key that shall be used for encoding/decoding.
private enum CodingKeys: String, CodingKey {
case customLanguageModel = "custom_language_model"
case speakerLabels = "speaker_labels"
case lowLatency = "low_latency"
}

}
262 changes: 181 additions & 81 deletions Sources/SpeechToTextV1/SpeechToText.swift

Large diffs are not rendered by default.

15 changes: 11 additions & 4 deletions Sources/TextToSpeechV1/Models/CustomModel.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright IBM Corp. 2020.
* (C) Copyright IBM Corp. 2021.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -62,12 +62,18 @@ public struct CustomModel: Codable, Equatable {

/**
An array of `Word` objects that lists the words and their translations from the custom model. The words are listed
in alphabetical order, with uppercase letters listed before lowercase letters. The array is empty if the custom
model contains no words. This field is returned only by the **Get a voice** method and only when you specify the
customization ID of a custom model.
in alphabetical order, with uppercase letters listed before lowercase letters. The array is empty if no words are
defined for the custom model. This field is returned only by the **Get a custom model** method.
*/
public var words: [Word]?

/**
An array of `Prompt` objects that provides information about the prompts that are defined for the specified custom
model. The array is empty if no prompts are defined for the custom model. This field is returned only by the **Get
a custom model** method.
*/
public var prompts: [Prompt]?

// Map each property name to the key that shall be used for encoding/decoding.
private enum CodingKeys: String, CodingKey {
case customizationID = "customization_id"
Expand All @@ -78,6 +84,7 @@ public struct CustomModel: Codable, Equatable {
case lastModified = "last_modified"
case description = "description"
case words = "words"
case prompts = "prompts"
}

}
65 changes: 65 additions & 0 deletions Sources/TextToSpeechV1/Models/Prompt.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/**
* (C) Copyright IBM Corp. 2021.
*
* 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 Foundation

/**
Information about a custom prompt.
*/
public struct Prompt: Codable, Equatable {

/**
The user-specified text of the prompt.
*/
public var prompt: String

/**
The user-specified identifier (name) of the prompt.
*/
public var promptID: String

/**
The status of the prompt:
* `processing`: The service received the request to add the prompt and is analyzing the validity of the prompt.
* `available`: The service successfully validated the prompt, which is now ready for use in a speech synthesis
request.
* `failed`: The service's validation of the prompt failed. The status of the prompt includes an `error` field that
describes the reason for the failure.
*/
public var status: String

/**
If the status of the prompt is `failed`, an error message that describes the reason for the failure. The field is
omitted if no error occurred.
*/
public var error: String?

/**
The speaker ID (GUID) of the speaker for which the prompt was defined. The field is omitted if no speaker ID was
specified.
*/
public var speakerID: String?

// Map each property name to the key that shall be used for encoding/decoding.
private enum CodingKeys: String, CodingKey {
case prompt = "prompt"
case promptID = "prompt_id"
case status = "status"
case error = "error"
case speakerID = "speaker_id"
}

}
66 changes: 66 additions & 0 deletions Sources/TextToSpeechV1/Models/PromptMetadata.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/**
* (C) Copyright IBM Corp. 2021.
*
* 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 Foundation

/**
Information about the prompt that is to be added to a custom model. The following example of a `PromptMetadata` object
includes both the required prompt text and an optional speaker model ID:
`{ "prompt_text": "Thank you and good-bye!", "speaker_id": "823068b2-ed4e-11ea-b6e0-7b6456aa95cc" }`.
*/
public struct PromptMetadata: Codable, Equatable {

/**
The required written text of the spoken prompt. The length of a prompt's text is limited to a few sentences.
Speaking one or two sentences of text is the recommended limit. A prompt cannot contain more than 1000 characters
of text. Escape any XML control characters (double quotes, single quotes, ampersands, angle brackets, and slashes)
that appear in the text of the prompt.
*/
public var promptText: String

/**
The optional speaker ID (GUID) of a previously defined speaker model that is to be associated with the prompt.
*/
public var speakerID: String?

// Map each property name to the key that shall be used for encoding/decoding.
private enum CodingKeys: String, CodingKey {
case promptText = "prompt_text"
case speakerID = "speaker_id"
}

/**
Initialize a `PromptMetadata` with member variables.
- parameter promptText: The required written text of the spoken prompt. The length of a prompt's text is limited
to a few sentences. Speaking one or two sentences of text is the recommended limit. A prompt cannot contain more
than 1000 characters of text. Escape any XML control characters (double quotes, single quotes, ampersands, angle
brackets, and slashes) that appear in the text of the prompt.
- parameter speakerID: The optional speaker ID (GUID) of a previously defined speaker model that is to be
associated with the prompt.
- returns: An initialized `PromptMetadata`.
*/
public init(
promptText: String,
speakerID: String? = nil
)
{
self.promptText = promptText
self.speakerID = speakerID
}

}
35 changes: 35 additions & 0 deletions Sources/TextToSpeechV1/Models/Prompts.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* (C) Copyright IBM Corp. 2021.
*
* 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 Foundation

/**
Information about the custom prompts that are defined for a custom model.
*/
public struct Prompts: Codable, Equatable {

/**
An array of `Prompt` objects that provides information about the prompts that are defined for the specified custom
model. The array is empty if no prompts are defined for the custom model.
*/
public var prompts: [Prompt]

// Map each property name to the key that shall be used for encoding/decoding.
private enum CodingKeys: String, CodingKey {
case prompts = "prompts"
}

}
40 changes: 40 additions & 0 deletions Sources/TextToSpeechV1/Models/Speaker.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* (C) Copyright IBM Corp. 2021.
*
* 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 Foundation

/**
Information about a speaker model.
*/
public struct Speaker: Codable, Equatable {

/**
The speaker ID (GUID) of the speaker.
*/
public var speakerID: String

/**
The user-defined name of the speaker.
*/
public var name: String

// Map each property name to the key that shall be used for encoding/decoding.
private enum CodingKeys: String, CodingKey {
case speakerID = "speaker_id"
case name = "name"
}

}
41 changes: 41 additions & 0 deletions Sources/TextToSpeechV1/Models/SpeakerCustomModel.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* (C) Copyright IBM Corp. 2021.
*
* 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 Foundation

/**
A custom models for which the speaker has defined prompts.
*/
public struct SpeakerCustomModel: Codable, Equatable {

/**
The customization ID (GUID) of a custom model for which the speaker has defined one or more prompts.
*/
public var customizationID: String

/**
An array of `SpeakerPrompt` objects that provides information about each prompt that the user has defined for the
custom model.
*/
public var prompts: [SpeakerPrompt]

// Map each property name to the key that shall be used for encoding/decoding.
private enum CodingKeys: String, CodingKey {
case customizationID = "customization_id"
case prompts = "prompts"
}

}
36 changes: 36 additions & 0 deletions Sources/TextToSpeechV1/Models/SpeakerCustomModels.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* (C) Copyright IBM Corp. 2021.
*
* 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 Foundation

/**
Custom models for which the speaker has defined prompts.
*/
public struct SpeakerCustomModels: Codable, Equatable {

/**
An array of `SpeakerCustomModel` objects. Each object provides information about the prompts that are defined for a
specified speaker in the custom models that are owned by a specified service instance. The array is empty if no
prompts are defined for the speaker.
*/
public var customizations: [SpeakerCustomModel]

// Map each property name to the key that shall be used for encoding/decoding.
private enum CodingKeys: String, CodingKey {
case customizations = "customizations"
}

}
34 changes: 34 additions & 0 deletions Sources/TextToSpeechV1/Models/SpeakerModel.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* (C) Copyright IBM Corp. 2021.
*
* 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 Foundation

/**
The speaker ID of the speaker model.
*/
public struct SpeakerModel: Codable, Equatable {

/**
The speaker ID (GUID) of the speaker model.
*/
public var speakerID: String

// Map each property name to the key that shall be used for encoding/decoding.
private enum CodingKeys: String, CodingKey {
case speakerID = "speaker_id"
}

}
Loading

0 comments on commit 7301a2f

Please sign in to comment.