1
1
mirror of https://github.com/leon-ai/leon.git synced 2024-09-19 22:07:10 +03:00

refactor(server): add STT parser parent class

This commit is contained in:
louistiti 2023-02-07 21:30:47 +08:00
parent 1146322196
commit ab0d88accf
4 changed files with 15 additions and 3 deletions

View File

@ -5,15 +5,18 @@ import wav from 'node-wav'
import { Model } from 'stt'
import type { STTParserFacade } from '@/core/stt/types'
import { STTParserBase } from '@/core/stt/stt-parser-base'
import { BIN_PATH } from '@/constants'
import { LogHelper } from '@/helpers/log-helper'
export class CoquiSTTParser implements STTParserFacade {
export class CoquiSTTParser extends STTParserBase implements STTParserFacade {
private readonly name = 'Coqui STT Parser'
private readonly model: Model | undefined = undefined
private readonly desiredSampleRate: number = 16_000
constructor() {
super()
LogHelper.title(this.name)
LogHelper.success('New instance')

View File

@ -3,14 +3,17 @@ import path from 'node:path'
import stt, { SpeechClient } from '@google-cloud/speech'
import type { STTParserFacade } from '@/core/stt/types'
import { STTParserBase } from '@/core/stt/stt-parser-base'
import { LANG, VOICE_CONFIG_PATH } from '@/constants'
import { LogHelper } from '@/helpers/log-helper'
export class GoogleCloudSTTParser implements STTParserFacade {
export class GoogleCloudSTTParser extends STTParserBase implements STTParserFacade {
private readonly name = 'Google Cloud STT Parser'
private readonly client: SpeechClient | undefined = undefined
constructor() {
super()
LogHelper.title(this.name)
LogHelper.success('New instance')

View File

@ -7,14 +7,17 @@ import { IamAuthenticator } from 'ibm-watson/auth'
import type { STTParserFacade } from '@/core/stt/types'
import type { WatsonVoiceConfiguration } from '@/schemas/voice-config-schemas'
import { STTParserBase } from '@/core/stt/stt-parser-base'
import { LANG, VOICE_CONFIG_PATH } from '@/constants'
import { LogHelper } from '@/helpers/log-helper'
export class WatsonSTTParser implements STTParserFacade {
export class WatsonSTTParser extends STTParserBase implements STTParserFacade {
private readonly name = 'Watson STT Parser'
private readonly client: Stt | undefined = undefined
constructor() {
super()
LogHelper.title(this.name)
LogHelper.success('New instance')

View File

@ -0,0 +1,3 @@
export class STTParserBase {
// Common methods and props for STT parsers
}