https://github.com/barisatamer/swiftgooglecloudtts
A client for Google Cloud Text-to-Speech, built on top of SwiftNIO
https://github.com/barisatamer/swiftgooglecloudtts
googlecloudplatform googlecloudtexttospeech swift5 swiftnio vapor-4
Last synced: 7 months ago
JSON representation
A client for Google Cloud Text-to-Speech, built on top of SwiftNIO
- Host: GitHub
- URL: https://github.com/barisatamer/swiftgooglecloudtts
- Owner: barisatamer
- Created: 2020-01-19T19:47:27.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2021-03-07T14:34:07.000Z (almost 5 years ago)
- Last Synced: 2025-04-29T07:41:11.495Z (10 months ago)
- Topics: googlecloudplatform, googlecloudtexttospeech, swift5, swiftnio, vapor-4
- Language: Swift
- Size: 42 KB
- Stars: 7
- Watchers: 1
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# SwiftGoogleCloudTTS
### Before you begin ⚠️
1. [Select or create a Cloud Platform project][projects].
1. [Enable billing for your project][billing].
1. [Enable the Google Cloud Text-to-Speech API][enable_api].
1. [Set up authentication with a service account][auth] so you can access the
API from your local workstation.
### Installation 📦
To include it in your package, add the following to your `Package.swift` file.
```swift
let package = Package(
name: "Project",
dependencies: [
...
.package(url: "https://github.com/barisatamer/SwiftGoogleCloudTTS.git", from: "0.0.5"),
],
targets: [
.target(name: "App", dependencies: ["SwiftGoogleCloudTTS", ... ])
]
)
```
### Setting the environment variable
```bash
export GOOGLE_APPLICATION_CREDENTIALS="[PATH]"
```
### Usage 🚀
```swift
import SwiftGoogleCloudTTS
let synthesizeSpeechRequest = Google_Cloud_Texttospeech_V1_SynthesizeSpeechRequest.with {
$0.input = Google_Cloud_Texttospeech_V1_SynthesisInput.with {
$0.text = "Text to speech testing"
}
$0.voice = Google_Cloud_Texttospeech_V1_VoiceSelectionParams.with {
$0.name = "en-US-Wavenet-A"
$0.languageCode = "en-US"
}
$0.audioConfig = Google_Cloud_Texttospeech_V1_AudioConfig.with {
$0.audioEncoding = Google_Cloud_Texttospeech_V1_AudioEncoding.mp3
}
}
do {
let response = try client.synthesizeSpeech(request: synthesizeSpeechRequest).wait()
// ..
} catch {
print(error)
}
```
[client-docs]: https://googleapis.dev/nodejs/text-to-speech/latest
[product-docs]: https://cloud.google.com/text-to-speech
[shell_img]: https://gstatic.com/cloudssh/images/open-btn.png
[projects]: https://console.cloud.google.com/project
[billing]: https://support.google.com/cloud/answer/6293499#enable-billing
[enable_api]: https://console.cloud.google.com/flows/enableapi?apiid=texttospeech.googleapis.com
[auth]: https://cloud.google.com/docs/authentication/getting-started