Skip to content

milosgajdos/go-playht

Repository files navigation

go-playht

Build Status go.dev reference License: Apache-2.0

Unofficial Go module for play.ht API client.

The official play.ht API documentation, upon which this Go module has been built, can be found here.

In order to use this Go module you must create an account with play.ht and generate API secret and retrieve your User ID. See the official docs here.

Get started

Get the module

go get ./...

Run tests:

go test -v ./...

There are a few code samples available in the examples directory so please do have a look. They could give you some idea about how to use this Go module.

Important

Before you attempt to run the samples you must set a couple of environment variables These are automatically read by the client when it gets created; you can override them in your own code.

  • PLAYHT_SECRET_KEY: API secret key
  • PLAYHT_USER_ID: Play.HT User ID

Nix

There is a Nix flake file vailable which lets you work on the Go module using nix.

Just run the following command and you are in the business:

nix develop

Basics

There are two ways to create audio/speech from the text using the API:

  • Job: audio generation is done in async; when you create a job you can monitor its progress via SSE
  • Stream: a real-time audio stream available immediately as soon as the stream has been created via the API

The API also allows you to clone a voice using a small sample of limited size. See the docs.

Note

the proto code was generated by running protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative proto/api.proto

TODO

  • Lease refresh for gRPC streaming