Swiftpack.co - barisatamer/SwiftGoogleCloudTTS as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by barisatamer.
barisatamer/SwiftGoogleCloudTTS 0.0.17
A client for Google Cloud Text-to-Speech, built on top of SwiftNIO
⭐️ 7
🕓 3 years ago
.package(url: "https://github.com/barisatamer/SwiftGoogleCloudTTS.git", from: "0.0.17")

SwiftGoogleCloudTTS

Swift 5.1 MIT License

Before you begin ⚠️

  1. Select or create a Cloud Platform project.
  2. Enable billing for your project.
  3. Enable the Google Cloud Text-to-Speech API.
  4. Set up authentication with a service account 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.

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

export GOOGLE_APPLICATION_CREDENTIALS="[PATH]"

Usage 🚀

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)
}

GitHub

link
Stars: 7
Last commit: 3 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics