generated from StanfordBDHG/SwiftPackageTemplate
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow voice selection and personal voices (#8)
# Allow voice selection and personal voices ## ♻️ Current situation & Problem Users can optionally specify a language for the voice to use when synthesizing speech, but cannot select a specific voice. As there are many voice options in iOS, including [personal voices](https://support.apple.com/en-us/104993), this would be a great feature to support. ## ⚙️ Release Notes - Allows users to specify a voice when generating speech. - Provides an array of voices in the user's current locale. - Provides a function for requesting permission and accessing personal voices. ## ✅ Testing - Updates the test app with a selection of voices that can be chosen to synthesize speech. - Personal voices cannot be tested on a simulator. ## 📝 Documentation - Updates the README with an example of voice selection in a SwiftUI interface - Adds instructions for requesting access to Personal Voices. ## 📝 Code of Conduct & Contributing Guidelines By submitting creating this pull request, you agree to follow our [Code of Conduct](https://github.com/StanfordSpezi/.github/blob/main/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/StanfordSpezi/.github/blob/main/CONTRIBUTING.md): - [X] I agree to follow the [Code of Conduct](https://github.com/StanfordSpezi/.github/blob/main/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/StanfordSpezi/.github/blob/main/CONTRIBUTING.md). --------- Co-authored-by: Paul Schmiedmayer <[email protected]>
- Loading branch information
1 parent
60b8cdb
commit 0b79f72
Showing
10 changed files
with
249 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// | ||
// This source file is part of the Stanford Spezi open-source project | ||
// | ||
// SPDX-FileCopyrightText: 2024 Stanford University and the project authors (see CONTRIBUTORS.md) | ||
// | ||
// SPDX-License-Identifier: MIT | ||
// | ||
|
||
import Speech | ||
import SpeziSpeechRecognizer | ||
import SpeziSpeechSynthesizer | ||
import SwiftUI | ||
|
||
struct SpeechVoiceSelectionTestView: View { | ||
@Environment(SpeechSynthesizer.self) private var speechSynthesizer | ||
@State private var selectedVoiceIndex = 0 | ||
@State private var message = "" | ||
|
||
var body: some View { | ||
VStack { | ||
TextField("Enter text to be spoken", text: $message) | ||
.textFieldStyle(RoundedBorderTextFieldStyle()) | ||
.padding() | ||
|
||
Picker("Voice", selection: $selectedVoiceIndex) { | ||
ForEach(speechSynthesizer.voices.indices, id: \.self) { index in | ||
Text(speechSynthesizer.voices[index].name) | ||
.tag(index) | ||
} | ||
} | ||
.pickerStyle(.inline) | ||
.accessibilityIdentifier("voicePicker") | ||
.padding() | ||
|
||
Button("Speak") { | ||
speechSynthesizer.speak( | ||
message, | ||
voice: speechSynthesizer.voices[selectedVoiceIndex] | ||
) | ||
} | ||
} | ||
.padding() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters