common

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2022 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

package common 一些有用的通用功能函数库

Index

Constants

This section is empty.

Variables

View Source
var (
	APIStatusCodeOK                 int = 200000 // OK
	APIStatusCodePartOK             int = 206000 // 部分识别结果
	APIStatusCodeClientError        int = 400000
	APIStatusCodeClientErrorFormat  int = 400001 // 请求数据格式错误
	APIStatusCodeClientErrorConfig  int = 400002 // 请求数据配置不支持
	APIStatusCodeServerError        int = 500000
	APIStatusCodeServerErrorRunning int = 500001 // 服务器运行中出错
)

Functions

func Base64ToBytes

func Base64ToBytes(base64Data string) []byte

Base64ToBytes base64编码数据转换为[]byte字节数组

func BytesToBase64

func BytesToBase64(bytesData []byte) string

BytesToBase64 []byte字节数组转换为base64编码数据

func ReadBinFile

func ReadBinFile(filename string) []byte

func SaveWaveObject

func SaveWaveObject(filename string, wave Wav) error

func SendHTTPRequest added in v1.1.1

func SendHTTPRequest(url string, method string,
	bytesBody []byte, contentType string,
) ([]byte, error)

SendHTTPRequest 发送HTTP请求

func SendHTTPRequestGet added in v1.1.0

func SendHTTPRequestGet(url string) ([]byte, error)

SendHTTPRequestGet 发送HTTP GET请求

func SendHTTPRequestPost added in v1.1.0

func SendHTTPRequestPost(url string, bytesForm []byte, contentType string) ([]byte, error)

SendHTTPRequestPost 发送HTTP POST请求

func URLDecode added in v1.1.0

func URLDecode(text string) string

URLDecode URL解码

func URLEncode added in v1.1.0

func URLEncode(text string) string

URLEncode URL编码

Types

type AsrtAPILanguageRequest added in v1.1.0

type AsrtAPILanguageRequest struct {
	SequencePinyin []string `json:"sequence_pinyin"`
}

AsrtAPILanguageRequest ASRT语音识别API语言模型请求类

type AsrtAPIResponse added in v1.1.0

type AsrtAPIResponse struct {
	StatusCode    int         `json:"status_code"`
	StatucMesaage string      `json:"status_message"`
	Result        interface{} `json:"result"`
}

AsrtAPIResponse ASRT语音识别API响应类

type AsrtAPISpeechRequest added in v1.1.0

type AsrtAPISpeechRequest struct {
	Samples    string `json:"samples"`
	SampleRate int    `json:"sample_rate"`
	Channels   int    `json:"channels"`
	ByteWidth  int    `json:"byte_width"`
}

AsrtAPISpeechRequest ASRT语音识别API语音数据请求类

type Wav

type Wav struct {
	// Samples 采样样本数据
	Samples [][]int16
	// FrameRate 采样频率,单位:Hz。例如:16000 / 8000 等
	FrameRate int
	// Channels 声音通道数,单声道为1,立体声为2
	Channels int
	// SampleWidth 采样位深,单位:字节(byte)
	SampleWidth int
	// BytesPerSec 比特率,单位:bps
	BytesPerSec int
	// contains filtered or unexported fields
}

Wav Wav格式结构对象

func NewBlankWav

func NewBlankWav(frameRate int, channels int, sampleWidth int) Wav

NewBlankWav 获取一个新的空白Wav对象

func (*Wav) AppendBlank

func (w *Wav) AppendBlank(millisecond uint32)
AppendBlank 在wave的后面追加一定时间的静音区,单位:毫秒。

这里用无符号类型是因为不允许添加负数时间长度

func (*Wav) AppendWav

func (w *Wav) AppendWav(wavAppended Wav) error

AppendWav 在本wave的samples后面追加给定wave的sample

func (*Wav) Deserialize

func (w *Wav) Deserialize(bytesData []byte) error

Deserialize Wave格式反序列化

func (*Wav) GetRawSamples

func (w *Wav) GetRawSamples() []byte

GetRawSamples 读取Wave格式的Samples原始数据

func (*Wav) Serialize

func (w *Wav) Serialize() ([]byte, error)

Serialize Wave格式序列化

Jump to

Keyboard shortcuts

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