import { ISpeechConfigAudioDevice } from "../../common.speech/Exports.js"; import { AudioSourceEvent, EventSource, IAudioSource, IAudioStreamNode } from "../../common/Exports.js"; import { AudioStreamFormat, PullAudioInputStreamCallback } from "../Exports.js"; import { AudioStreamFormatImpl } from "./AudioStreamFormat.js"; /** * Represents audio input stream used for custom audio input configurations. * @class AudioInputStream */ export declare abstract class AudioInputStream { /** * Creates and initializes an instance. * @constructor */ protected constructor(); /** * Creates a memory backed PushAudioInputStream with the specified audio format. * @member AudioInputStream.createPushStream * @function * @public * @param {AudioStreamFormat} format - The audio data format in which audio will be * written to the push audio stream's write() method (Required if format is not 16 kHz 16bit mono PCM). * @returns {PushAudioInputStream} The audio input stream being created. */ static createPushStream(format?: AudioStreamFormat): PushAudioInputStream; /** * Creates a PullAudioInputStream that delegates to the specified callback interface for read() * and close() methods. * @member AudioInputStream.createPullStream * @function * @public * @param {PullAudioInputStreamCallback} callback - The custom audio input object, derived from * PullAudioInputStreamCallback * @param {AudioStreamFormat} format - The audio data format in which audio will be returned from * the callback's read() method (Required if format is not 16 kHz 16bit mono PCM). * @returns {PullAudioInputStream} The audio input stream being created. */ static createPullStream(callback: PullAudioInputStreamCallback, format?: AudioStreamFormat): PullAudioInputStream; /** * Explicitly frees any external resource attached to the object * @member AudioInputStream.prototype.close * @function * @public */ abstract close(): void; } /** * Represents memory backed push audio input stream used for custom audio input configurations. * @class PushAudioInputStream */ export declare abstract class PushAudioInputStream extends AudioInputStream { /** * Creates a memory backed PushAudioInputStream with the specified audio format. * @member PushAudioInputStream.create * @function * @public * @param {AudioStreamFormat} format - The audio data format in which audio will be written to the * push audio stream's write() method (Required if format is not 16 kHz 16bit mono PCM). * @returns {PushAudioInputStream} The push audio input stream being created. */ static create(format?: AudioStreamFormat): PushAudioInputStream; /** * Writes the audio data specified by making an internal copy of the data. * @member PushAudioInputStream.prototype.write * @function * @public * @param {ArrayBuffer} dataBuffer - The audio buffer of which this function will make a copy. */ abstract write(dataBuffer: ArrayBuffer): void; /** * Requests that the audio written so far be finalized as a completed * segment, without ending or restarting the current recognition turn. * * The call is non-blocking. The commit is anchored to the audio written before the call, * so write the audio for the segment first, then call this method. * * The request is advisory. A token is issued as soon as the request is recorded, but there * is no guarantee that it will be acknowledged: the service may not support inline commit, * or the session may end first. Applications must tolerate a token that is never echoed. * A commit not yet delivered when the stream is closed is discarded, since end of audio * finalizes the same audio. * * Supported with SpeechRecognizer, TranslationRecognizer and ConversationTranscriber, * for PCM, A-law and mu-law audio. * * Throws if the stream has been closed, or if channelId is not an integer from 0 to * 4294967295. * @member PushAudioInputStream.prototype.commit * @function * @public * @param {number} channelId - Optional 0-based index of the channel to commit on * multichannel input. If omitted, the commit applies to all channels. * @returns {number} A token greater than 0 that the recognition result acknowledging * the commit carries in its commitToken property, or 0 if the request was rejected: * more than one commit within 100 ms on this stream, or an audio format that does not * support commit. */ abstract commit(channelId?: number): number; /** * Closes the stream. * @member PushAudioInputStream.prototype.close * @function * @public */ abstract close(): void; } /** * Represents memory backed push audio input stream used for custom audio input configurations. * @private * @class PushAudioInputStreamImpl */ export declare class PushAudioInputStreamImpl extends PushAudioInputStream implements IAudioSource { private privFormat; private privId; private privEvents; private privStream; private privNextCommitToken; private privLastCommitTime; private privUndeliveredCommits; private static readonly CommitMinIntervalMs; /** * Creates and initalizes an instance with the given values. * @constructor * @param {AudioStreamFormat} format - The audio stream format. */ constructor(format?: AudioStreamFormat); /** * Format information for the audio */ get format(): Promise; /** * Writes the audio data specified by making an internal copy of the data. * @member PushAudioInputStreamImpl.prototype.write * @function * @public * @param {ArrayBuffer} dataBuffer - The audio buffer of which this function will make a copy. */ write(dataBuffer: ArrayBuffer): void; /** * Closes the stream. * @member PushAudioInputStreamImpl.prototype.close * @function * @public */ close(): void; /** * Requests a segmentation boundary after the audio written so far. * @member PushAudioInputStreamImpl.prototype.commit * @function * @public * @param {number} channelId - Optional 0-based channel index; all channels if omitted. * @returns {number} A token greater than 0, or 0 if the request was rejected. */ commit(channelId?: number): number; id(): string; turnOn(): Promise; attach(audioNodeId: string): Promise; detach(audioNodeId: string): void; turnOff(): Promise; get events(): EventSource; get deviceInfo(): Promise; private onEvent; private static log; private static monotonicNow; private toBuffer; } export declare abstract class PullAudioInputStream extends AudioInputStream { /** * Creates and initializes and instance. * @constructor */ protected constructor(); /** * Creates a PullAudioInputStream that delegates to the specified callback interface for * read() and close() methods, using the default format (16 kHz 16bit mono PCM). * @member PullAudioInputStream.create * @function * @public * @param {PullAudioInputStreamCallback} callback - The custom audio input object, * derived from PullAudioInputStreamCustomCallback * @param {AudioStreamFormat} format - The audio data format in which audio will be * returned from the callback's read() method (Required if format is not 16 kHz 16bit mono PCM). * @returns {PullAudioInputStream} The push audio input stream being created. */ static create(callback: PullAudioInputStreamCallback, format?: AudioStreamFormat): PullAudioInputStream; /** * Explicitly frees any external resource attached to the object * @member PullAudioInputStream.prototype.close * @function * @public */ abstract close(): void; } /** * Represents audio input stream used for custom audio input configurations. * @private * @class PullAudioInputStreamImpl */ export declare class PullAudioInputStreamImpl extends PullAudioInputStream implements IAudioSource { private privCallback; private privFormat; private privId; private privEvents; private privIsClosed; private privBufferSize; /** * Creates a PullAudioInputStream that delegates to the specified callback interface for * read() and close() methods, using the default format (16 kHz 16bit mono PCM). * @constructor * @param {PullAudioInputStreamCallback} callback - The custom audio input object, * derived from PullAudioInputStreamCustomCallback * @param {AudioStreamFormat} format - The audio data format in which audio will be * returned from the callback's read() method (Required if format is not 16 kHz 16bit mono PCM). */ constructor(callback: PullAudioInputStreamCallback, format?: AudioStreamFormatImpl); /** * Format information for the audio */ get format(): Promise; /** * Closes the stream. * @member PullAudioInputStreamImpl.prototype.close * @function * @public */ close(): void; id(): string; turnOn(): Promise; attach(audioNodeId: string): Promise; detach(audioNodeId: string): void; turnOff(): Promise; get events(): EventSource; get deviceInfo(): Promise; private onEvent; }