Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support g722-16khz-64kbps audio output format #815

Merged
merged 1 commit into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/sdk/Audio/AudioOutputFormat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ export class AudioOutputFormatImpl extends AudioStreamFormatImpl {
[SpeechSynthesisOutputFormat.Riff22050Hz16BitMonoPcm]: "riff-22050hz-16bit-mono-pcm",
[SpeechSynthesisOutputFormat.Raw44100Hz16BitMonoPcm]: "raw-44100hz-16bit-mono-pcm",
[SpeechSynthesisOutputFormat.Riff44100Hz16BitMonoPcm]: "riff-44100hz-16bit-mono-pcm",
[SpeechSynthesisOutputFormat.AmrWb16000Hz]: "amr-wb-16000hz",
[SpeechSynthesisOutputFormat.G72216Khz64Kbps]: "g722-16khz-64kbps",
};
private priAudioFormatString: string;
/**
Expand Down Expand Up @@ -519,6 +521,28 @@ export class AudioOutputFormatImpl extends AudioStreamFormatImpl {
speechSynthesisOutputFormatString,
"raw-44100hz-16bit-mono-pcm",
true);
case "amr-wb-16000h":
return new AudioOutputFormatImpl(
AudioFormatTag.AMR_WB,
1,
16000,
3052,
2,
16,
speechSynthesisOutputFormatString,
speechSynthesisOutputFormatString,
Copy link
Contributor

@BrianMouncer BrianMouncer Apr 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you sure this second line is correct.
looks like cut and past error, when compared to some of the other formats that have an actual literal format sting in the second position.

e.g. should it have one of these new values.

    [SpeechSynthesisOutputFormat.AmrWb16000Hz]: "amr-wb-16000hz",
    [SpeechSynthesisOutputFormat.G72216Khz64Kbps]: "g722-16khz-64kbps",

Copy link
Contributor Author

@yulin-li yulin-li Apr 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for noticing this.

The two formats (customer request to sdk and sdk requests to service) are different if the format has header. E.g., we will replace riff to raw to get the streaming output.

For the new added formats in this PR, they have no header so the two lines should be same

false);
case "g722-16khz-64kbps":
return new AudioOutputFormatImpl(
AudioFormatTag.G722,
1,
16000,
8000,
2,
16,
speechSynthesisOutputFormatString,
speechSynthesisOutputFormatString,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same question/comment here

false);
case "riff-16khz-16bit-mono-pcm":
default:
return new AudioOutputFormatImpl(
Expand Down
2 changes: 2 additions & 0 deletions src/sdk/Audio/AudioStreamFormat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export enum AudioFormatTag {
ALaw,
FLAC,
OPUS,
AMR_WB,
G722,
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/sdk/Audio/SpeakerAudioDestination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ const AudioFormatToMimeType: INumberDictionary<string> = {
[AudioFormatTag.WEBM_OPUS]: "audio/webm; codecs=opus",
[AudioFormatTag.ALaw]: "audio/x-wav",
[AudioFormatTag.FLAC]: "audio/flac",
[AudioFormatTag.AMR_WB]: "audio/amr-wb",
[AudioFormatTag.G722]: "audio/G722",
};

/**
Expand Down
17 changes: 16 additions & 1 deletion src/sdk/SpeechSynthesisOutputFormat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,5 +251,20 @@ export enum SpeechSynthesisOutputFormat {
* Added in version 1.22.0
* @member SpeechSynthesisOutputFormat.Riff44100Hz16BitMonoPcm
*/
Riff44100Hz16BitMonoPcm
Riff44100Hz16BitMonoPcm,

/**
* amr-wb-16000hz
* AMR-WB audio at 16kHz sampling rate.
* Added in version 1.38.0
* @member SpeechSynthesisOutputFormat.AmrWb16000Hz
*/
AmrWb16000Hz,

/**
* g722-16khz-64kbps
* G.722 audio at 16kHz sampling rate and 64kbps bitrate.
* Added in version 1.38.0
*/
G72216Khz64Kbps
}