Documentation
¶
Overview ¶
Package oggwriter implements OGG media container writer
Index ¶
- Constants
- Variables
- func GetLanguageCode(serviceType, lang string, f func(string) (string, error)) (string, error)
- func GranulePosition(config byte) uint64
- func InitLogger(config *Config)
- func NewAmazonTranscribeClientV2(c Config) (*transcribestreaming.Client, error)
- func NewAmazonTranscribeV2Handler(config Config, channelID, connectionID string, sampleRate uint32, ...) serviceHandlerInterface
- func NewLogger(config *Config, logFilename string, logDomain string) (*zerolog.Logger, error)
- func NewPacketDumpHandler(config Config, channelID, connectionID string, sampleRate uint32, ...) serviceHandlerInterface
- func NewSpeechToTextHandler(config Config, channelID, connectionID string, sampleRate uint32, ...) serviceHandlerInterface
- func NewSpeechpbRecognitionConfig(rc RecognitionConfig) *speechpb.RecognitionConfig
- func NewStartStreamTranscriptionInputV2(at *AmazonTranscribeV2) transcribestreaming.StartStreamTranscriptionInput
- func NewStreamingRecognitionConfig(recognitionConfig *speechpb.RecognitionConfig, ...) *speechpb.StreamingRecognizeRequest_StreamingConfig
- func NewTestHandler(config Config, channelID, connectionID string, sampleRate uint32, ...) serviceHandlerInterface
- func ShowConfig(config *Config)
- type AmazonTranscribeV2
- type AmazonTranscribeV2Handler
- func (h *AmazonTranscribeV2Handler) GetRetryCount() int
- func (h *AmazonTranscribeV2Handler) Handle(ctx context.Context, opusCh chan opus, header soraHeader) (*io.PipeReader, error)
- func (h *AmazonTranscribeV2Handler) IsRetryTarget(args any) bool
- func (h *AmazonTranscribeV2Handler) ResetRetryCount() int
- func (h *AmazonTranscribeV2Handler) UpdateRetryCount() int
- type AwsResultV2
- type Config
- type GcpResult
- type OggWriter
- type PacketDumpHandler
- func (h *PacketDumpHandler) GetRetryCount() int
- func (h *PacketDumpHandler) Handle(ctx context.Context, opusCh chan opus, header soraHeader) (*io.PipeReader, error)
- func (h *PacketDumpHandler) IsRetryTarget(any) bool
- func (h *PacketDumpHandler) ResetRetryCount() int
- func (h *PacketDumpHandler) UpdateRetryCount() int
- type PacketDumpResult
- type RecognitionConfig
- type Server
- type SpeechToText
- type SpeechToTextHandler
- func (h *SpeechToTextHandler) GetRetryCount() int
- func (h *SpeechToTextHandler) Handle(ctx context.Context, opusCh chan opus, header soraHeader) (*io.PipeReader, error)
- func (h *SpeechToTextHandler) IsRetryTarget(args any) bool
- func (h *SpeechToTextHandler) ResetRetryCount() int
- func (h *SpeechToTextHandler) UpdateRetryCount() int
- type SuzuConfError
- type SuzuError
- type TestHandler
- type TestResult
- type TranscriptionResult
Constants ¶
View Source
const ( // timestamp(64), sequence number(64), length(32) HeaderLength = 20 MaxPayloadLength = 0xffffff ErrPayloadTooLarge = "PAYLOAD-TOO-LARGE: %d" )
View Source
const (
FrameSize = 1024 * 10
)
Variables ¶
View Source
var ( ErrMissingAudioStreamingLanguageCode = fmt.Errorf("MISSING-SORA-AUDIO-STREAMING-LANGUAGE-CODE") ErrUnsupportedLanguageCode = fmt.Errorf("UNSUPPORTED-LANGUAGE-CODE") ErrUnsupportedService = fmt.Errorf("UNSUPPORTED-SERVICE") )
View Source
var ( NewServiceHandlerFuncs = make(newServiceHandlerFuncs) ErrServiceNotFound = fmt.Errorf("SERVICE-NOT-FOUND") )
View Source
var ( // TODO: 分かりにくい場合はエラー名を変更する // このエラーの場合は再接続を試みる ErrServerDisconnected = fmt.Errorf("SERVER-DISCONNECTED") )
View Source
var Version string
Functions ¶
func GetLanguageCode ¶
func GranulePosition ¶
func InitLogger ¶
func InitLogger(config *Config)
func NewAmazonTranscribeClientV2 ¶
func NewAmazonTranscribeClientV2(c Config) (*transcribestreaming.Client, error)
func NewPacketDumpHandler ¶
func NewSpeechToTextHandler ¶
func NewSpeechpbRecognitionConfig ¶
func NewSpeechpbRecognitionConfig(rc RecognitionConfig) *speechpb.RecognitionConfig
func NewStartStreamTranscriptionInputV2 ¶
func NewStartStreamTranscriptionInputV2(at *AmazonTranscribeV2) transcribestreaming.StartStreamTranscriptionInput
func NewStreamingRecognitionConfig ¶
func NewStreamingRecognitionConfig(recognitionConfig *speechpb.RecognitionConfig, singleUtterance, interimResults bool) *speechpb.StreamingRecognizeRequest_StreamingConfig
func NewTestHandler ¶
func ShowConfig ¶
func ShowConfig(config *Config)
Types ¶
type AmazonTranscribeV2 ¶
type AmazonTranscribeV2 struct {
LanguageCode string
MediaEncoding types.MediaEncoding
MediaSampleRateHertz int64
EnablePartialResultsStabilization bool
NumberOfChannels int64
EnableChannelIdentification bool
PartialResultsStability string
Region string
SessionID string
Debug bool
Config Config
}
func NewAmazonTranscribeV2 ¶
func NewAmazonTranscribeV2(c Config, languageCode string, sampleRateHertz, audioChannelCount int64) *AmazonTranscribeV2
func (*AmazonTranscribeV2) Start ¶
func (at *AmazonTranscribeV2) Start(ctx context.Context, r io.ReadCloser, header soraHeader) (*transcribestreaming.StartStreamTranscriptionEventStream, error)
type AmazonTranscribeV2Handler ¶
type AmazonTranscribeV2Handler struct {
Config Config
ChannelID string
ConnectionID string
SampleRate uint32
ChannelCount uint16
LanguageCode string
RetryCount int
OnResultFunc func(context.Context, io.WriteCloser, string, string, string, any) error
// contains filtered or unexported fields
}
func (*AmazonTranscribeV2Handler) GetRetryCount ¶
func (h *AmazonTranscribeV2Handler) GetRetryCount() int
func (*AmazonTranscribeV2Handler) Handle ¶
func (h *AmazonTranscribeV2Handler) Handle(ctx context.Context, opusCh chan opus, header soraHeader) (*io.PipeReader, error)
func (*AmazonTranscribeV2Handler) IsRetryTarget ¶
func (h *AmazonTranscribeV2Handler) IsRetryTarget(args any) bool
func (*AmazonTranscribeV2Handler) ResetRetryCount ¶
func (h *AmazonTranscribeV2Handler) ResetRetryCount() int
func (*AmazonTranscribeV2Handler) UpdateRetryCount ¶
func (h *AmazonTranscribeV2Handler) UpdateRetryCount() int
type AwsResultV2 ¶
type AwsResultV2 struct {
ChannelID *string `json:"channel_id,omitempty"`
IsPartial *bool `json:"is_partial,omitempty"`
ResultID *string `json:"result_id,omitempty"`
TranscriptionResult
}
func NewAwsResultV2 ¶
func NewAwsResultV2() AwsResultV2
func (*AwsResultV2) SetMessage ¶
func (ar *AwsResultV2) SetMessage(message string) *AwsResultV2
func (*AwsResultV2) WithChannelID ¶
func (ar *AwsResultV2) WithChannelID(channelID string) *AwsResultV2
func (*AwsResultV2) WithIsPartial ¶
func (ar *AwsResultV2) WithIsPartial(isPartial bool) *AwsResultV2
func (*AwsResultV2) WithResultID ¶
func (ar *AwsResultV2) WithResultID(resultID string) *AwsResultV2
type Config ¶
type Config struct {
Version string
Debug bool `ini:"debug"`
HTTPS bool `ini:"https"`
ListenAddr string `ini:"listen_addr"`
ListenPort int `ini:"listen_port"`
AudioStreamingHeader bool `ini:"audio_streaming_header"`
TLSFullchainFile string `ini:"tls_fullchain_file"`
TLSPrivkeyFile string `ini:"tls_privkey_file"`
TLSVerifyCacertPath string `ini:"tls_verify_cacert_path"` // クライアント認証用
HTTP2MaxConcurrentStreams uint32 `ini:"http2_max_concurrent_streams"`
HTTP2MaxReadFrameSize uint32 `ini:"http2_max_read_frame_size"`
HTTP2IdleTimeout uint32 `ini:"http2_idle_timeout"`
MaxRetry int `ini:"max_retry"`
RetryIntervalMs int `ini:"retry_interval_ms"`
RetryTargets []string `ini:"retry_targets"`
ExporterHTTPS bool `ini:"exporter_https"`
ExporterListenAddr string `ini:"exporter_listen_addr"`
ExporterListenPort int `ini:"exporter_listen_port"`
SkipBasicAuth bool `ini:"skip_basic_auth"`
BasicAuthUsername string `ini:"basic_auth_username"`
BasicAuthPassword string `ini:"basic_auth_password"`
SampleRate int `ini:"audio_sample_rate"`
ChannelCount int `ini:"audio_channel_count"`
EnableOggFileOutput bool `ini:"enable_ogg_file_output"`
OggDir string `ini:"ogg_dir"`
DumpFile string `ini:"dump_file"`
LogDir string `ini:"log_dir"`
LogName string `ini:"log_name"`
LogStdout bool `ini:"log_stdout"`
LogRotateMaxSize int `ini:"log_rotate_max_size"`
LogRotateMaxBackups int `ini:"log_rotate_max_backups"`
LogRotateMaxAge int `ini:"log_rotate_max_age"`
LogRotateCompress bool `ini:"log_rotate_compress"`
LogMessageKeyName string `ini:"log_message_key_name"`
LogTimestampKeyName string `ini:"log_timestamp_key_name"`
DebugConsoleLog bool `ini:"debug_console_log"`
DebugConsoleLogJSON bool `ini:"debug_console_log_json"`
DisableSilentPacket bool `ini:"disable_silent_packet"`
TimeToWaitForOpusPacketMs int `ini:"time_to_wait_for_opus_packet_ms"`
// aws の場合は IsPartial が false, gcp の場合は IsFinal が true の場合にのみ結果を返す指定
FinalResultOnly bool `ini:"final_result_only"`
MinimumConfidenceScore float64 `ini:"minimum_confidence_score"`
MinimumTranscribedTime float64 `ini:"minimum_transcribed_time"`
// Amazon Web Services
AwsCredentialFile string `ini:"aws_credential_file"`
AwsProfile string `ini:"aws_profile"`
AwsRegion string `ini:"aws_region"`
AwsEnablePartialResultsStabilization bool `ini:"aws_enable_partial_results_stabilization"`
AwsPartialResultsStability string `ini:"aws_partial_results_stability"`
AwsEnableChannelIdentification bool `ini:"aws_enable_channel_identification"`
// 変換結果に含める項目の有無の指定
AwsResultChannelID bool `ini:"aws_result_channel_id"`
AwsResultIsPartial bool `ini:"aws_result_is_partial"`
AwsResultID bool `ini:"aws_result_id"`
// AWS HTTP Transport 設定
AwsHTTPDisableKeepAlives bool `ini:"aws_http_disable_keep_alives"`
AwsHTTPIdleConnTimeoutSec int `ini:"aws_http_idle_conn_timeout_sec"`
AwsHTTPMaxIdleConns int `ini:"aws_http_max_idle_conns"`
AwsHTTPMaxIdleConnsPerHost int `ini:"aws_http_max_idle_conns_per_host"`
AwsHTTPMaxConnsPerHost int `ini:"aws_http_max_conns_per_host"`
AwsHTTPResponseHeaderTimeoutMs int `ini:"aws_http_response_header_timeout_ms"`
AwsHTTPExpectContinueTimeoutMs int `ini:"aws_http_expect_continue_timeout_ms"`
AwsHTTPTLSHandshakeTimeoutMs int `ini:"aws_http_tls_handshake_timeout_ms"`
// Google Cloud Platform
GcpCredentialFile string `ini:"gcp_credential_file"`
GcpEnableSeparateRecognitionPerChannel bool `ini:"gcp_enable_separate_recognition_per_channel"`
GcpAlternativeLanguageCodes []string `ini:"gcp_alternative_language_codes"`
GcpMaxAlternatives int32 `ini:"gcp_max_alternatives"`
GcpProfanityFilter bool `ini:"gcp_profanity_filter"`
GcpEnableWordTimeOffsets bool `ini:"gcp_enable_word_time_offsets"`
GcpEnableWordConfidence bool `ini:"gcp_enable_word_confidence"`
GcpEnableAutomaticPunctuation bool `ini:"gcp_enable_automatic_punctuation"`
GcpEnableSpokenPunctuation bool `ini:"gcp_enable_spoken_punctuation"`
GcpEnableSpokenEmojis bool `ini:"gcp_enable_spoken_emojis"`
GcpModel string `ini:"gcp_model"`
GcpUseEnhanced bool `ini:"gcp_use_enhanced"`
GcpSingleUtterance bool `ini:"gcp_single_utterance"`
GcpInterimResults bool `ini:"gcp_interim_results"`
// 変換結果に含める項目の有無の指定
GcpResultIsFinal bool `ini:"gcp_result_is_final"`
GcpResultStability bool `ini:"gcp_result_stability"`
}
type GcpResult ¶
type GcpResult struct {
IsFinal *bool `json:"is_final,omitempty"`
Stability *float32 `json:"stability,omitempty"`
TranscriptionResult
}
func NewGcpResult ¶
func NewGcpResult() GcpResult
func (*GcpResult) SetMessage ¶
func (*GcpResult) WithIsFinal ¶
func (*GcpResult) WithStability ¶
type OggWriter ¶
type OggWriter struct {
// contains filtered or unexported fields
}
OggWriter is used to take RTP packets and write them to an OGG on disk
type PacketDumpHandler ¶
type PacketDumpHandler struct {
Config Config
ChannelID string
ConnectionID string
SampleRate uint32
ChannelCount uint16
LanguageCode string
RetryCount int
OnResultFunc func(context.Context, io.WriteCloser, string, string, string, any) error
// contains filtered or unexported fields
}
func (*PacketDumpHandler) GetRetryCount ¶
func (h *PacketDumpHandler) GetRetryCount() int
func (*PacketDumpHandler) Handle ¶
func (h *PacketDumpHandler) Handle(ctx context.Context, opusCh chan opus, header soraHeader) (*io.PipeReader, error)
func (*PacketDumpHandler) IsRetryTarget ¶
func (h *PacketDumpHandler) IsRetryTarget(any) bool
IsRetryTarget は本ハンドラではリトライしないため、常に false を返す
func (*PacketDumpHandler) ResetRetryCount ¶
func (h *PacketDumpHandler) ResetRetryCount() int
func (*PacketDumpHandler) UpdateRetryCount ¶
func (h *PacketDumpHandler) UpdateRetryCount() int
type PacketDumpResult ¶
type PacketDumpResult struct {
Timestamp int64 `json:"timestamp"`
ChannelID string `json:"channel_id"`
ConnectionID string `json:"connection_id"`
LanguageCode string `json:"language_code"`
SampleRate uint32 `json:"sample_rate"`
ChannelCount uint16 `json:"channel_count"`
Payload []byte `json:"payload"`
}
type RecognitionConfig ¶
type RecognitionConfig struct {
Encoding speechpb.RecognitionConfig_AudioEncoding
SampleRateHertz int32
AudioChannelCount int32
EnableSeparateRecognitionPerChannel bool
LanguageCode string
AlternativeLanguageCodes []string
MaxAlternatives int32
ProfanityFilter bool
SpeechContexts []*speechpb.SpeechContext
EnableWordTimeOffsets bool
EnableWordConfidence bool
EnableAutomaticPunctuation bool
EnableSpokenPunctuation bool
EnableSpokenEmojis bool
Model string
UseEnhanced bool
}
func NewRecognitionConfig ¶
func NewRecognitionConfig(c Config, languageCode string, sampleRate, channelCount int32) RecognitionConfig
type SpeechToText ¶
func NewSpeechToText ¶
func NewSpeechToText(config Config, languageCode string, sampleRate, channelCount int32) SpeechToText
func (SpeechToText) Start ¶
func (stt SpeechToText) Start(ctx context.Context, r io.ReadCloser, header soraHeader) (speechpb.Speech_StreamingRecognizeClient, error)
type SpeechToTextHandler ¶
type SpeechToTextHandler struct {
Config Config
ChannelID string
ConnectionID string
SampleRate uint32
ChannelCount uint16
LanguageCode string
RetryCount int
OnResultFunc func(context.Context, io.WriteCloser, string, string, string, any) error
// contains filtered or unexported fields
}
func (*SpeechToTextHandler) GetRetryCount ¶
func (h *SpeechToTextHandler) GetRetryCount() int
func (*SpeechToTextHandler) Handle ¶
func (h *SpeechToTextHandler) Handle(ctx context.Context, opusCh chan opus, header soraHeader) (*io.PipeReader, error)
func (*SpeechToTextHandler) IsRetryTarget ¶
func (h *SpeechToTextHandler) IsRetryTarget(args any) bool
func (*SpeechToTextHandler) ResetRetryCount ¶
func (h *SpeechToTextHandler) ResetRetryCount() int
func (*SpeechToTextHandler) UpdateRetryCount ¶
func (h *SpeechToTextHandler) UpdateRetryCount() int
type SuzuConfError ¶
type SuzuConfError struct {
Message string
}
func NewSuzuConfError ¶
func NewSuzuConfError(err error) *SuzuConfError
func (*SuzuConfError) Error ¶
func (e *SuzuConfError) Error() string
type TestHandler ¶
type TestHandler struct {
Config Config
ChannelID string
ConnectionID string
SampleRate uint32
ChannelCount uint16
LanguageCode string
RetryCount int
OnResultFunc func(context.Context, io.WriteCloser, string, string, string, any) error
// contains filtered or unexported fields
}
func (*TestHandler) GetRetryCount ¶
func (h *TestHandler) GetRetryCount() int
func (*TestHandler) Handle ¶
func (h *TestHandler) Handle(ctx context.Context, opusCh chan opus, header soraHeader) (*io.PipeReader, error)
func (*TestHandler) IsRetryTarget ¶
func (h *TestHandler) IsRetryTarget(any) bool
IsRetryTarget は本ハンドラではリトライしないため、常に false を返す
func (*TestHandler) ResetRetryCount ¶
func (h *TestHandler) ResetRetryCount() int
func (*TestHandler) UpdateRetryCount ¶
func (h *TestHandler) UpdateRetryCount() int
type TestResult ¶
type TestResult struct {
ChannelID *string `json:"channel_id,omitempty"`
TranscriptionResult
}
func NewTestResult ¶
func NewTestResult(channelID, message string) TestResult
type TranscriptionResult ¶
type TranscriptionResult struct {
Message string `json:"message,omitempty"`
Reason string `json:"reason,omitempty"`
Type string `json:"type"`
}
func NewSuzuErrorResponse ¶
func NewSuzuErrorResponse(err error) TranscriptionResult
Source Files
¶
Click to show internal directories.
Click to hide internal directories.