import {TMGPTT} from './TMGPTT';
import {ITMG_VOICE_TYPE} from './TMGType';

export class TMGPTTImpl implements TMGPTT {
  private ptt: TMGPTTBindings|undefined;

  constructor(contextBindings: TMGContextBindings) {
    this.ptt = new TMGPTTBindings(contextBindings);
  }

  ApplyPTTAuthbuffer(userSig: string): number {
    return this.ptt.applyPTTAuthbuffer(userSig);
  }

  SetMaxMessageLength(msTime: number): number {
    return this.ptt.setMaxMessageLength(msTime);
  }

  StartRecording(filePath: string): number {
    return this.ptt.startRecording(filePath);
  }

  StopRecording(): number {
    return this.ptt.stopRecording();
  }

  CancelRecording(): number {
    return this.ptt.cancelRecording();
  }

  UploadRecordedFile(filePath: string): number {
    return this.ptt.uploadRecordedFile(filePath);
  }

  DownloadRecordedFile(fileId: string, filePath: string): number {
    return this.ptt.downloadRecordedFile(fileId, filePath);
  }

  PlayRecordedFile(filePath: string, voiceType?: ITMG_VOICE_TYPE): number {
    if (voiceType === undefined)
      return this.ptt.playRecordedFile(filePath, 0);
    return this.ptt.playRecordedFile(filePath, voiceType);
  }

  StopPlayFile(): number {
    return this.ptt.stopPlayFile();
  }

  SpeechToText(fileID: string, speechLanguage?: string, translateLanguage?: string): number {
    return this.ptt.speechToText(fileID, speechLanguage, translateLanguage);
  }

  TranslateText(text: string, sourceLanguage: string, translateLanguage: string): number {
    return this.ptt.translateText(text, sourceLanguage, translateLanguage);
  }

  GetFileSize(filePath: string): number {
    return this.ptt.getFileSize(filePath);
  }

  GetVoiceFileDuration(filePath: string): number {
    return this.ptt.getVoiceFileDuration(filePath);
  }

  StartRecordingWithStreamingRecognition(
      filePath: string, speechLanguage?: string, translateLanguage?: string): number {
    return this.ptt.startRecordingWithStreamingRecognition(
        filePath, speechLanguage, translateLanguage);
  }

  SetPTTSourceLanguage(sourceLanguage: string): number {
    return this.ptt.setPTTSourceLanguage(sourceLanguage);
  }

  TextToSpeech(
      serialNumber: number, text: string, voiceName: string, languageCode: string,
      speakingRate: number): number {
    return this.ptt.textToSpeech(serialNumber, text, voiceName, languageCode, speakingRate);
  }
}
