salutespeech_api

package module
v0.0.0-...-6fa39cd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 1, 2024 License: BSD-3-Clause Imports: 12 Imported by: 1

README

Salute Speech API

Простой доступ к API Salute Speech для Golang. Распознавание и Синтер речи. Самый простой доступ по REST.

Установка
go get github.com/saintbyte/salute_speech_api
Использование
import (
salute_speech_api "github.com/saintbyte/salute_speech_api"
)

Некоторые вещи придется проверят самому , такие как длина распозноваемого аудио

Задать переменную среды SALUTE_SPEECH_AUTH_DATA из "Авторизационные данные" в настройка проекта который находиться в пространстве.

Возможно задать пути к времененым файлами с авторизацией. По умолчанию файлы будут валяться в текущей папке.

  • SALUTE_TOKEN_FILE - Путь к файлу с токеном. Пример: /tmp/.salute_speech_token
  • SALUTE_EXPIRES_FILE - Путь к файлу с временем устаревания токена . Пример: /tmp/.salute_speech_expires

Есть пример .env - .env_examle

И подробнее о функциях: https://pkg.go.dev/github.com/saintbyte/salute_speech_api

Примеры

см. в директории examples

Documentation

Index

Constants

View Source
const (
	SaluteSpeechApi_InputAudioTypePCM_S16LE = "PCM_S16LE"
	SaluteSpeechApi_InputAudioTypeOPUS      = "OPUS"
	SaluteSpeechApi_InputAudioTypeMP3       = "MP3"
	SaluteSpeechApi_InputAudioTypeFLAC      = "FLAC"
	SaluteSpeechApi_InputAudioTypeALAW      = "ALAW"
	SaluteSpeechApi_InputAudioTypeMULAW     = "MULAW"

	SaluteSpeechApi_OutputAudioTypeWAV16 = "wav16"
	SaluteSpeechApi_OutputAudioTypePCM16 = "pcm16"
	SaluteSpeechApi_OutputAudioTypeOPUS  = "opus"
	SaluteSpeechApi_OutputAudioTypeALAW  = "alaw"
)
View Source
const (
	SaluteSpeechApiRestURL     = "https://smartspeech.sber.ru/rest/v1/"
	SaluteSpeechOauthUrl       = "https://ngw.devices.sberbank.ru:9443/api/v2/oauth"
	SaluteSpeechTokenFileEnv   = "SALUTE_TOKEN_FILE"
	SaluteSpeechExpiresFileEnv = "SALUTE_EXPIRES_FILE"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type SaluteSpeechApi

type SaluteSpeechApi struct {
	AudioType         string
	Voice             *Voice
	Rate              int
	ValidateVoiceName bool
	Debug             bool
}

func NewSaluteSpeechApi

func NewSaluteSpeechApi() *SaluteSpeechApi

func (*SaluteSpeechApi) Auth

func (s *SaluteSpeechApi) Auth() (int64, string)

func (*SaluteSpeechApi) GetVoiceById

func (s *SaluteSpeechApi) GetVoiceById(voice_id string) *Voice

func (*SaluteSpeechApi) Recognize

func (s *SaluteSpeechApi) Recognize(data io.Reader) (*SpeechRecognizeAnswer, error)

func (*SaluteSpeechApi) RecognizeFile

func (s *SaluteSpeechApi) RecognizeFile(filename string) (*SpeechRecognizeAnswer, error)

func (*SaluteSpeechApi) Synthesize

func (s *SaluteSpeechApi) Synthesize(text2speech_or_ssml string) (io.Reader, error)

func (*SaluteSpeechApi) SynthesizeToFile

func (s *SaluteSpeechApi) SynthesizeToFile(filename string, text2speech_or_ssml string) error

type SpeechRecognizeAnswer

type SpeechRecognizeAnswer struct {
	Result   []string `json:"result"`
	Emotions []struct {
		Negative float64 `json:"negative"`
		Neutral  float64 `json:"neutral"`
		Positive float64 `json:"positive"`
	} `json:"emotions,omitempty"`
	PersonIdentity struct {
		Age         string `json:"age"`
		Gender      string `json:"gender"`
		AgeScore    int    `json:"age_score"`
		GenderScore int    `json:"gender_score"`
	} `json:"person_identity,omitempty"`
	Status int `json:"status"`
}

type TokenResponse

type TokenResponse struct {
	AccessToken string `json:"access_token"`
	ExpiresAt   int64  `json:"expires_at"`
}

type Voice

type Voice struct {
	Id     string
	Name   string
	Lang   string
	Gender string
	Rate   int
}

func SaluteSpeechVoices

func SaluteSpeechVoices() []Voice

Directories

Path Synopsis
examples
recognize command
synthesize command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL