@cartesia/cartesia-js 2.0.2 → 2.0.4-alpha0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Client.d.ts +3 -0
- package/Client.js +18 -9
- package/README.md +1 -5
- package/api/index.js +17 -1
- package/api/resources/apiStatus/client/Client.js +33 -6
- package/api/resources/apiStatus/client/index.js +2 -1
- package/api/resources/apiStatus/index.js +18 -2
- package/api/resources/apiStatus/types/ApiInfo.js +2 -1
- package/api/resources/apiStatus/types/index.js +17 -1
- package/api/resources/datasets/client/Client.d.ts +70 -0
- package/api/resources/datasets/client/Client.js +261 -0
- package/api/resources/datasets/client/index.d.ts +1 -0
- package/api/resources/datasets/client/index.js +17 -0
- package/api/resources/datasets/client/requests/UploadDatasetFileRequest.d.ts +11 -0
- package/api/resources/datasets/client/requests/UploadDatasetFileRequest.js +5 -0
- package/api/resources/datasets/client/requests/index.d.ts +1 -0
- package/api/resources/datasets/client/requests/index.js +2 -0
- package/api/resources/datasets/index.d.ts +2 -0
- package/api/resources/datasets/index.js +18 -0
- package/api/resources/datasets/types/CreateDatasetRequest.d.ts +6 -0
- package/api/resources/datasets/types/CreateDatasetRequest.js +5 -0
- package/api/resources/datasets/types/Dataset.d.ts +8 -0
- package/api/resources/datasets/types/Dataset.js +5 -0
- package/api/resources/datasets/types/DatasetFile.d.ts +8 -0
- package/api/resources/datasets/types/DatasetFile.js +5 -0
- package/api/resources/datasets/types/FilePurpose.d.ts +7 -0
- package/api/resources/datasets/types/FilePurpose.js +9 -0
- package/api/resources/datasets/types/PaginatedDatasetFiles.d.ts +8 -0
- package/api/resources/datasets/types/PaginatedDatasetFiles.js +5 -0
- package/api/resources/datasets/types/PaginatedDatasets.d.ts +8 -0
- package/api/resources/datasets/types/PaginatedDatasets.js +5 -0
- package/api/resources/datasets/types/index.d.ts +6 -0
- package/api/resources/datasets/types/index.js +22 -0
- package/api/resources/embedding/index.js +17 -1
- package/api/resources/embedding/types/Embedding.js +2 -1
- package/api/resources/embedding/types/index.js +17 -1
- package/api/resources/index.d.ts +3 -0
- package/api/resources/index.js +44 -12
- package/api/resources/tts/client/Client.js +40 -10
- package/api/resources/tts/client/index.js +2 -1
- package/api/resources/tts/index.js +18 -2
- package/api/resources/tts/types/CancelContextRequest.js +2 -1
- package/api/resources/tts/types/ContextId.js +2 -1
- package/api/resources/tts/types/Controls.js +2 -1
- package/api/resources/tts/types/Emotion.js +4 -1
- package/api/resources/tts/types/GenerationRequest.js +2 -1
- package/api/resources/tts/types/Mp3OutputFormat.js +2 -1
- package/api/resources/tts/types/NaturalSpecifier.js +4 -1
- package/api/resources/tts/types/NumericalSpecifier.js +2 -1
- package/api/resources/tts/types/OutputFormat.js +2 -1
- package/api/resources/tts/types/RawEncoding.js +4 -1
- package/api/resources/tts/types/RawOutputFormat.js +2 -1
- package/api/resources/tts/types/Speed.js +2 -1
- package/api/resources/tts/types/SupportedLanguage.js +4 -1
- package/api/resources/tts/types/TtsRequest.js +2 -1
- package/api/resources/tts/types/TtsRequestEmbeddingSpecifier.js +2 -1
- package/api/resources/tts/types/TtsRequestIdSpecifier.js +2 -1
- package/api/resources/tts/types/TtsRequestVoiceSpecifier.js +2 -1
- package/api/resources/tts/types/WavOutputFormat.js +2 -1
- package/api/resources/tts/types/WebSocketBaseResponse.js +2 -1
- package/api/resources/tts/types/WebSocketChunkResponse.js +2 -1
- package/api/resources/tts/types/WebSocketDoneResponse.js +2 -1
- package/api/resources/tts/types/WebSocketErrorResponse.js +2 -1
- package/api/resources/tts/types/WebSocketRawOutputFormat.js +2 -1
- package/api/resources/tts/types/WebSocketRequest.js +2 -1
- package/api/resources/tts/types/WebSocketResponse.js +2 -1
- package/api/resources/tts/types/WebSocketStreamOptions.js +2 -1
- package/api/resources/tts/types/WebSocketTimestampsResponse.js +2 -1
- package/api/resources/tts/types/WebSocketTtsOutput.js +2 -1
- package/api/resources/tts/types/WebSocketTtsRequest.js +2 -1
- package/api/resources/tts/types/WordTimestamps.js +2 -1
- package/api/resources/tts/types/index.js +46 -30
- package/api/resources/voiceChanger/client/Client.js +40 -10
- package/api/resources/voiceChanger/client/index.js +17 -1
- package/api/resources/voiceChanger/client/requests/VoiceChangerBytesRequest.js +2 -1
- package/api/resources/voiceChanger/client/requests/VoiceChangerSseRequest.js +2 -1
- package/api/resources/voiceChanger/client/requests/index.js +2 -1
- package/api/resources/voiceChanger/index.js +18 -2
- package/api/resources/voiceChanger/types/OutputFormatContainer.js +4 -1
- package/api/resources/voiceChanger/types/StreamingResponse.js +2 -1
- package/api/resources/voiceChanger/types/index.js +18 -2
- package/api/resources/voices/client/Client.js +52 -22
- package/api/resources/voices/client/index.js +17 -1
- package/api/resources/voices/client/requests/CloneVoiceRequest.js +2 -1
- package/api/resources/voices/client/requests/index.js +2 -1
- package/api/resources/voices/index.js +18 -2
- package/api/resources/voices/types/BaseVoiceId.js +2 -1
- package/api/resources/voices/types/CloneMode.js +4 -1
- package/api/resources/voices/types/CreateVoiceRequest.js +2 -1
- package/api/resources/voices/types/EmbeddingResponse.js +2 -1
- package/api/resources/voices/types/EmbeddingSpecifier.js +2 -1
- package/api/resources/voices/types/Gender.js +4 -1
- package/api/resources/voices/types/IdSpecifier.js +2 -1
- package/api/resources/voices/types/LocalizeDialect.d.ts +11 -11
- package/api/resources/voices/types/LocalizeDialect.js +2 -7
- package/api/resources/voices/types/LocalizeEnglishDialect.d.ts +11 -0
- package/api/resources/voices/types/LocalizeEnglishDialect.js +13 -0
- package/api/resources/voices/types/LocalizeTargetLanguage.js +4 -1
- package/api/resources/voices/types/LocalizeVoiceRequest.js +2 -1
- package/api/resources/voices/types/MixVoiceSpecifier.js +2 -1
- package/api/resources/voices/types/MixVoicesRequest.js +2 -1
- package/api/resources/voices/types/UpdateVoiceRequest.js +2 -1
- package/api/resources/voices/types/Voice.js +2 -1
- package/api/resources/voices/types/VoiceId.js +2 -1
- package/api/resources/voices/types/VoiceMetadata.js +2 -1
- package/api/resources/voices/types/Weight.js +2 -1
- package/api/resources/voices/types/index.d.ts +1 -0
- package/api/resources/voices/types/index.js +34 -17
- package/core/fetcher/APIResponse.js +2 -1
- package/core/fetcher/Fetcher.js +18 -14
- package/core/fetcher/Supplier.js +4 -1
- package/core/fetcher/createRequestUrl.js +10 -3
- package/core/fetcher/getFetchFn.js +33 -6
- package/core/fetcher/getHeader.js +5 -1
- package/core/fetcher/getRequestBody.js +5 -1
- package/core/fetcher/getResponseBody.js +7 -3
- package/core/fetcher/index.js +9 -3
- package/core/fetcher/makeRequest.js +8 -4
- package/core/fetcher/requestWithRetries.js +5 -1
- package/core/fetcher/signals.js +7 -2
- package/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.js +5 -1
- package/core/fetcher/stream-wrappers/NodePre18StreamWrapper.js +5 -1
- package/core/fetcher/stream-wrappers/UndiciStreamWrapper.js +5 -1
- package/core/fetcher/stream-wrappers/chooseStreamWrapper.js +34 -7
- package/core/form-data-utils/FormDataWrapper.js +41 -11
- package/core/form-data-utils/index.js +17 -1
- package/core/index.d.ts +1 -1
- package/core/index.js +34 -5
- package/core/runtime/index.js +5 -1
- package/core/runtime/runtime.js +4 -1
- package/core/schemas/Schema.js +4 -1
- package/core/schemas/builders/bigint/bigint.js +13 -9
- package/core/schemas/builders/bigint/index.js +5 -1
- package/core/schemas/builders/date/date.js +14 -10
- package/core/schemas/builders/date/index.js +5 -1
- package/core/schemas/builders/enum/enum.js +11 -7
- package/core/schemas/builders/enum/index.js +5 -1
- package/core/schemas/builders/index.js +30 -14
- package/core/schemas/builders/lazy/index.js +7 -2
- package/core/schemas/builders/lazy/lazy.js +11 -5
- package/core/schemas/builders/lazy/lazyObject.js +11 -7
- package/core/schemas/builders/list/index.js +5 -1
- package/core/schemas/builders/list/list.js +12 -8
- package/core/schemas/builders/literals/booleanLiteral.js +10 -6
- package/core/schemas/builders/literals/index.js +7 -2
- package/core/schemas/builders/literals/stringLiteral.js +10 -6
- package/core/schemas/builders/object/index.js +11 -3
- package/core/schemas/builders/object/object.js +38 -33
- package/core/schemas/builders/object/objectWithoutOptionalProperties.js +7 -3
- package/core/schemas/builders/object/property.js +7 -2
- package/core/schemas/builders/object/types.js +2 -1
- package/core/schemas/builders/object-like/getObjectLikeUtils.js +15 -10
- package/core/schemas/builders/object-like/index.js +6 -1
- package/core/schemas/builders/object-like/types.js +2 -1
- package/core/schemas/builders/primitives/any.js +6 -3
- package/core/schemas/builders/primitives/boolean.js +8 -5
- package/core/schemas/builders/primitives/index.js +13 -5
- package/core/schemas/builders/primitives/number.js +8 -5
- package/core/schemas/builders/primitives/string.js +8 -5
- package/core/schemas/builders/primitives/unknown.js +6 -3
- package/core/schemas/builders/record/index.js +5 -1
- package/core/schemas/builders/record/record.js +18 -14
- package/core/schemas/builders/record/types.js +2 -1
- package/core/schemas/builders/schema-utils/JsonError.js +7 -3
- package/core/schemas/builders/schema-utils/ParseError.js +7 -3
- package/core/schemas/builders/schema-utils/getSchemaUtils.js +15 -9
- package/core/schemas/builders/schema-utils/index.js +11 -3
- package/core/schemas/builders/schema-utils/stringifyValidationErrors.js +5 -1
- package/core/schemas/builders/set/index.js +5 -1
- package/core/schemas/builders/set/set.js +14 -10
- package/core/schemas/builders/undiscriminated-union/index.js +5 -1
- package/core/schemas/builders/undiscriminated-union/types.js +2 -1
- package/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.js +10 -6
- package/core/schemas/builders/union/discriminant.js +5 -1
- package/core/schemas/builders/union/index.js +7 -2
- package/core/schemas/builders/union/types.js +2 -1
- package/core/schemas/builders/union/union.js +18 -14
- package/core/schemas/index.js +17 -1
- package/core/schemas/utils/MaybePromise.js +2 -1
- package/core/schemas/utils/addQuestionMarksToNullableProperties.js +2 -1
- package/core/schemas/utils/createIdentitySchemaCreator.js +8 -4
- package/core/schemas/utils/entries.js +5 -1
- package/core/schemas/utils/filterObject.js +5 -1
- package/core/schemas/utils/getErrorMessageForIncorrectType.js +5 -1
- package/core/schemas/utils/isPlainObject.js +5 -1
- package/core/schemas/utils/keys.js +5 -1
- package/core/schemas/utils/maybeSkipValidation.js +5 -1
- package/core/schemas/utils/partition.js +5 -1
- package/core/streaming-fetcher/Stream.js +9 -4
- package/core/streaming-fetcher/index.js +5 -1
- package/core/websocket/events.js +9 -3
- package/core/websocket/index.js +17 -1
- package/core/websocket/ws.js +33 -6
- package/dist/Client.d.ts +3 -0
- package/dist/Client.js +18 -9
- package/dist/api/index.js +17 -1
- package/dist/api/resources/apiStatus/client/Client.js +33 -6
- package/dist/api/resources/apiStatus/client/index.js +2 -1
- package/dist/api/resources/apiStatus/index.js +18 -2
- package/dist/api/resources/apiStatus/types/ApiInfo.js +2 -1
- package/dist/api/resources/apiStatus/types/index.js +17 -1
- package/dist/api/resources/datasets/client/Client.d.ts +70 -0
- package/dist/api/resources/datasets/client/Client.js +261 -0
- package/dist/api/resources/datasets/client/index.d.ts +1 -0
- package/dist/api/resources/datasets/client/index.js +17 -0
- package/dist/api/resources/datasets/client/requests/UploadDatasetFileRequest.d.ts +11 -0
- package/dist/api/resources/datasets/client/requests/UploadDatasetFileRequest.js +5 -0
- package/dist/api/resources/datasets/client/requests/index.d.ts +1 -0
- package/dist/api/resources/datasets/client/requests/index.js +2 -0
- package/dist/api/resources/datasets/index.d.ts +2 -0
- package/dist/api/resources/datasets/index.js +18 -0
- package/dist/api/resources/datasets/types/CreateDatasetRequest.d.ts +6 -0
- package/dist/api/resources/datasets/types/CreateDatasetRequest.js +5 -0
- package/dist/api/resources/datasets/types/Dataset.d.ts +8 -0
- package/dist/api/resources/datasets/types/Dataset.js +5 -0
- package/dist/api/resources/datasets/types/DatasetFile.d.ts +8 -0
- package/dist/api/resources/datasets/types/DatasetFile.js +5 -0
- package/dist/api/resources/datasets/types/FilePurpose.d.ts +7 -0
- package/dist/api/resources/datasets/types/FilePurpose.js +9 -0
- package/dist/api/resources/datasets/types/PaginatedDatasetFiles.d.ts +8 -0
- package/dist/api/resources/datasets/types/PaginatedDatasetFiles.js +5 -0
- package/dist/api/resources/datasets/types/PaginatedDatasets.d.ts +8 -0
- package/dist/api/resources/datasets/types/PaginatedDatasets.js +5 -0
- package/dist/api/resources/datasets/types/index.d.ts +6 -0
- package/dist/api/resources/datasets/types/index.js +22 -0
- package/dist/api/resources/embedding/index.js +17 -1
- package/dist/api/resources/embedding/types/Embedding.js +2 -1
- package/dist/api/resources/embedding/types/index.js +17 -1
- package/dist/api/resources/index.d.ts +3 -0
- package/dist/api/resources/index.js +44 -12
- package/dist/api/resources/tts/client/Client.js +40 -10
- package/dist/api/resources/tts/client/index.js +2 -1
- package/dist/api/resources/tts/index.js +18 -2
- package/dist/api/resources/tts/types/CancelContextRequest.js +2 -1
- package/dist/api/resources/tts/types/ContextId.js +2 -1
- package/dist/api/resources/tts/types/Controls.js +2 -1
- package/dist/api/resources/tts/types/Emotion.js +4 -1
- package/dist/api/resources/tts/types/GenerationRequest.js +2 -1
- package/dist/api/resources/tts/types/Mp3OutputFormat.js +2 -1
- package/dist/api/resources/tts/types/NaturalSpecifier.js +4 -1
- package/dist/api/resources/tts/types/NumericalSpecifier.js +2 -1
- package/dist/api/resources/tts/types/OutputFormat.js +2 -1
- package/dist/api/resources/tts/types/RawEncoding.js +4 -1
- package/dist/api/resources/tts/types/RawOutputFormat.js +2 -1
- package/dist/api/resources/tts/types/Speed.js +2 -1
- package/dist/api/resources/tts/types/SupportedLanguage.js +4 -1
- package/dist/api/resources/tts/types/TtsRequest.js +2 -1
- package/dist/api/resources/tts/types/TtsRequestEmbeddingSpecifier.js +2 -1
- package/dist/api/resources/tts/types/TtsRequestIdSpecifier.js +2 -1
- package/dist/api/resources/tts/types/TtsRequestVoiceSpecifier.js +2 -1
- package/dist/api/resources/tts/types/WavOutputFormat.js +2 -1
- package/dist/api/resources/tts/types/WebSocketBaseResponse.js +2 -1
- package/dist/api/resources/tts/types/WebSocketChunkResponse.js +2 -1
- package/dist/api/resources/tts/types/WebSocketDoneResponse.js +2 -1
- package/dist/api/resources/tts/types/WebSocketErrorResponse.js +2 -1
- package/dist/api/resources/tts/types/WebSocketRawOutputFormat.js +2 -1
- package/dist/api/resources/tts/types/WebSocketRequest.js +2 -1
- package/dist/api/resources/tts/types/WebSocketResponse.js +2 -1
- package/dist/api/resources/tts/types/WebSocketStreamOptions.js +2 -1
- package/dist/api/resources/tts/types/WebSocketTimestampsResponse.js +2 -1
- package/dist/api/resources/tts/types/WebSocketTtsOutput.js +2 -1
- package/dist/api/resources/tts/types/WebSocketTtsRequest.js +2 -1
- package/dist/api/resources/tts/types/WordTimestamps.js +2 -1
- package/dist/api/resources/tts/types/index.js +46 -30
- package/dist/api/resources/voiceChanger/client/Client.js +40 -10
- package/dist/api/resources/voiceChanger/client/index.js +17 -1
- package/dist/api/resources/voiceChanger/client/requests/VoiceChangerBytesRequest.js +2 -1
- package/dist/api/resources/voiceChanger/client/requests/VoiceChangerSseRequest.js +2 -1
- package/dist/api/resources/voiceChanger/client/requests/index.js +2 -1
- package/dist/api/resources/voiceChanger/index.js +18 -2
- package/dist/api/resources/voiceChanger/types/OutputFormatContainer.js +4 -1
- package/dist/api/resources/voiceChanger/types/StreamingResponse.js +2 -1
- package/dist/api/resources/voiceChanger/types/index.js +18 -2
- package/dist/api/resources/voices/client/Client.js +52 -22
- package/dist/api/resources/voices/client/index.js +17 -1
- package/dist/api/resources/voices/client/requests/CloneVoiceRequest.js +2 -1
- package/dist/api/resources/voices/client/requests/index.js +2 -1
- package/dist/api/resources/voices/index.js +18 -2
- package/dist/api/resources/voices/types/BaseVoiceId.js +2 -1
- package/dist/api/resources/voices/types/CloneMode.js +4 -1
- package/dist/api/resources/voices/types/CreateVoiceRequest.js +2 -1
- package/dist/api/resources/voices/types/EmbeddingResponse.js +2 -1
- package/dist/api/resources/voices/types/EmbeddingSpecifier.js +2 -1
- package/dist/api/resources/voices/types/Gender.js +4 -1
- package/dist/api/resources/voices/types/IdSpecifier.js +2 -1
- package/dist/api/resources/voices/types/LocalizeDialect.d.ts +11 -11
- package/dist/api/resources/voices/types/LocalizeDialect.js +2 -7
- package/dist/api/resources/voices/types/LocalizeEnglishDialect.d.ts +11 -0
- package/dist/api/resources/voices/types/LocalizeEnglishDialect.js +13 -0
- package/dist/api/resources/voices/types/LocalizeTargetLanguage.js +4 -1
- package/dist/api/resources/voices/types/LocalizeVoiceRequest.js +2 -1
- package/dist/api/resources/voices/types/MixVoiceSpecifier.js +2 -1
- package/dist/api/resources/voices/types/MixVoicesRequest.js +2 -1
- package/dist/api/resources/voices/types/UpdateVoiceRequest.js +2 -1
- package/dist/api/resources/voices/types/Voice.js +2 -1
- package/dist/api/resources/voices/types/VoiceId.js +2 -1
- package/dist/api/resources/voices/types/VoiceMetadata.js +2 -1
- package/dist/api/resources/voices/types/Weight.js +2 -1
- package/dist/api/resources/voices/types/index.d.ts +1 -0
- package/dist/api/resources/voices/types/index.js +34 -17
- package/dist/core/fetcher/APIResponse.js +2 -1
- package/dist/core/fetcher/Fetcher.js +18 -14
- package/dist/core/fetcher/Supplier.js +4 -1
- package/dist/core/fetcher/createRequestUrl.js +10 -3
- package/dist/core/fetcher/getFetchFn.js +33 -6
- package/dist/core/fetcher/getHeader.js +5 -1
- package/dist/core/fetcher/getRequestBody.js +5 -1
- package/dist/core/fetcher/getResponseBody.js +7 -3
- package/dist/core/fetcher/index.js +9 -3
- package/dist/core/fetcher/makeRequest.js +8 -4
- package/dist/core/fetcher/requestWithRetries.js +5 -1
- package/dist/core/fetcher/signals.js +7 -2
- package/dist/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.js +5 -1
- package/dist/core/fetcher/stream-wrappers/NodePre18StreamWrapper.js +5 -1
- package/dist/core/fetcher/stream-wrappers/UndiciStreamWrapper.js +5 -1
- package/dist/core/fetcher/stream-wrappers/chooseStreamWrapper.js +34 -7
- package/dist/core/form-data-utils/FormDataWrapper.js +41 -11
- package/dist/core/form-data-utils/index.js +17 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +34 -5
- package/dist/core/runtime/index.js +5 -1
- package/dist/core/runtime/runtime.js +4 -1
- package/dist/core/schemas/Schema.js +4 -1
- package/dist/core/schemas/builders/bigint/bigint.js +13 -9
- package/dist/core/schemas/builders/bigint/index.js +5 -1
- package/dist/core/schemas/builders/date/date.js +14 -10
- package/dist/core/schemas/builders/date/index.js +5 -1
- package/dist/core/schemas/builders/enum/enum.js +11 -7
- package/dist/core/schemas/builders/enum/index.js +5 -1
- package/dist/core/schemas/builders/index.js +30 -14
- package/dist/core/schemas/builders/lazy/index.js +7 -2
- package/dist/core/schemas/builders/lazy/lazy.js +11 -5
- package/dist/core/schemas/builders/lazy/lazyObject.js +11 -7
- package/dist/core/schemas/builders/list/index.js +5 -1
- package/dist/core/schemas/builders/list/list.js +12 -8
- package/dist/core/schemas/builders/literals/booleanLiteral.js +10 -6
- package/dist/core/schemas/builders/literals/index.js +7 -2
- package/dist/core/schemas/builders/literals/stringLiteral.js +10 -6
- package/dist/core/schemas/builders/object/index.js +11 -3
- package/dist/core/schemas/builders/object/object.js +38 -33
- package/dist/core/schemas/builders/object/objectWithoutOptionalProperties.js +7 -3
- package/dist/core/schemas/builders/object/property.js +7 -2
- package/dist/core/schemas/builders/object/types.js +2 -1
- package/dist/core/schemas/builders/object-like/getObjectLikeUtils.js +15 -10
- package/dist/core/schemas/builders/object-like/index.js +6 -1
- package/dist/core/schemas/builders/object-like/types.js +2 -1
- package/dist/core/schemas/builders/primitives/any.js +6 -3
- package/dist/core/schemas/builders/primitives/boolean.js +8 -5
- package/dist/core/schemas/builders/primitives/index.js +13 -5
- package/dist/core/schemas/builders/primitives/number.js +8 -5
- package/dist/core/schemas/builders/primitives/string.js +8 -5
- package/dist/core/schemas/builders/primitives/unknown.js +6 -3
- package/dist/core/schemas/builders/record/index.js +5 -1
- package/dist/core/schemas/builders/record/record.js +18 -14
- package/dist/core/schemas/builders/record/types.js +2 -1
- package/dist/core/schemas/builders/schema-utils/JsonError.js +7 -3
- package/dist/core/schemas/builders/schema-utils/ParseError.js +7 -3
- package/dist/core/schemas/builders/schema-utils/getSchemaUtils.js +15 -9
- package/dist/core/schemas/builders/schema-utils/index.js +11 -3
- package/dist/core/schemas/builders/schema-utils/stringifyValidationErrors.js +5 -1
- package/dist/core/schemas/builders/set/index.js +5 -1
- package/dist/core/schemas/builders/set/set.js +14 -10
- package/dist/core/schemas/builders/undiscriminated-union/index.js +5 -1
- package/dist/core/schemas/builders/undiscriminated-union/types.js +2 -1
- package/dist/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.js +10 -6
- package/dist/core/schemas/builders/union/discriminant.js +5 -1
- package/dist/core/schemas/builders/union/index.js +7 -2
- package/dist/core/schemas/builders/union/types.js +2 -1
- package/dist/core/schemas/builders/union/union.js +18 -14
- package/dist/core/schemas/index.js +17 -1
- package/dist/core/schemas/utils/MaybePromise.js +2 -1
- package/dist/core/schemas/utils/addQuestionMarksToNullableProperties.js +2 -1
- package/dist/core/schemas/utils/createIdentitySchemaCreator.js +8 -4
- package/dist/core/schemas/utils/entries.js +5 -1
- package/dist/core/schemas/utils/filterObject.js +5 -1
- package/dist/core/schemas/utils/getErrorMessageForIncorrectType.js +5 -1
- package/dist/core/schemas/utils/isPlainObject.js +5 -1
- package/dist/core/schemas/utils/keys.js +5 -1
- package/dist/core/schemas/utils/maybeSkipValidation.js +5 -1
- package/dist/core/schemas/utils/partition.js +5 -1
- package/dist/core/streaming-fetcher/Stream.js +9 -4
- package/dist/core/streaming-fetcher/index.js +5 -1
- package/dist/core/websocket/events.js +9 -3
- package/dist/core/websocket/index.js +17 -1
- package/dist/core/websocket/ws.js +33 -6
- package/dist/environments.js +4 -1
- package/dist/errors/CartesiaError.js +5 -1
- package/dist/errors/CartesiaTimeoutError.js +5 -1
- package/dist/errors/index.js +7 -2
- package/dist/index.js +34 -4
- package/dist/serialization/index.js +17 -1
- package/dist/serialization/resources/apiStatus/index.js +17 -1
- package/dist/serialization/resources/apiStatus/types/ApiInfo.js +28 -2
- package/dist/serialization/resources/apiStatus/types/index.js +17 -1
- package/dist/serialization/resources/datasets/index.d.ts +1 -0
- package/dist/serialization/resources/datasets/index.js +17 -0
- package/dist/serialization/resources/datasets/types/CreateDatasetRequest.d.ts +12 -0
- package/dist/serialization/resources/datasets/types/CreateDatasetRequest.js +33 -0
- package/dist/serialization/resources/datasets/types/Dataset.d.ts +14 -0
- package/dist/serialization/resources/datasets/types/Dataset.js +35 -0
- package/dist/serialization/resources/datasets/types/DatasetFile.d.ts +14 -0
- package/dist/serialization/resources/datasets/types/DatasetFile.js +35 -0
- package/dist/serialization/resources/datasets/types/FilePurpose.d.ts +10 -0
- package/dist/serialization/resources/datasets/types/FilePurpose.js +31 -0
- package/dist/serialization/resources/datasets/types/PaginatedDatasetFiles.d.ts +14 -0
- package/dist/serialization/resources/datasets/types/PaginatedDatasetFiles.js +35 -0
- package/dist/serialization/resources/datasets/types/PaginatedDatasets.d.ts +14 -0
- package/dist/serialization/resources/datasets/types/PaginatedDatasets.js +35 -0
- package/dist/serialization/resources/datasets/types/index.d.ts +6 -0
- package/dist/serialization/resources/datasets/types/index.js +22 -0
- package/dist/serialization/resources/embedding/index.js +17 -1
- package/dist/serialization/resources/embedding/types/Embedding.js +28 -2
- package/dist/serialization/resources/embedding/types/index.js +17 -1
- package/dist/serialization/resources/index.d.ts +2 -0
- package/dist/serialization/resources/index.js +41 -10
- package/dist/serialization/resources/tts/index.js +17 -1
- package/dist/serialization/resources/tts/types/CancelContextRequest.js +30 -4
- package/dist/serialization/resources/tts/types/ContextId.js +28 -2
- package/dist/serialization/resources/tts/types/Controls.js +32 -6
- package/dist/serialization/resources/tts/types/Emotion.js +28 -2
- package/dist/serialization/resources/tts/types/GenerationRequest.js +36 -10
- package/dist/serialization/resources/tts/types/Mp3OutputFormat.js +28 -2
- package/dist/serialization/resources/tts/types/NaturalSpecifier.js +28 -2
- package/dist/serialization/resources/tts/types/NumericalSpecifier.js +28 -2
- package/dist/serialization/resources/tts/types/OutputFormat.js +34 -8
- package/dist/serialization/resources/tts/types/RawEncoding.js +28 -2
- package/dist/serialization/resources/tts/types/RawOutputFormat.js +30 -4
- package/dist/serialization/resources/tts/types/Speed.js +30 -4
- package/dist/serialization/resources/tts/types/SupportedLanguage.js +28 -2
- package/dist/serialization/resources/tts/types/TtsRequest.js +34 -8
- package/dist/serialization/resources/tts/types/TtsRequestEmbeddingSpecifier.js +32 -6
- package/dist/serialization/resources/tts/types/TtsRequestIdSpecifier.js +32 -6
- package/dist/serialization/resources/tts/types/TtsRequestVoiceSpecifier.js +30 -4
- package/dist/serialization/resources/tts/types/WavOutputFormat.js +29 -3
- package/dist/serialization/resources/tts/types/WebSocketBaseResponse.js +30 -4
- package/dist/serialization/resources/tts/types/WebSocketChunkResponse.js +30 -4
- package/dist/serialization/resources/tts/types/WebSocketDoneResponse.js +29 -3
- package/dist/serialization/resources/tts/types/WebSocketErrorResponse.js +30 -4
- package/dist/serialization/resources/tts/types/WebSocketRawOutputFormat.js +30 -4
- package/dist/serialization/resources/tts/types/WebSocketRequest.js +30 -4
- package/dist/serialization/resources/tts/types/WebSocketResponse.js +36 -10
- package/dist/serialization/resources/tts/types/WebSocketStreamOptions.js +28 -2
- package/dist/serialization/resources/tts/types/WebSocketTimestampsResponse.js +32 -6
- package/dist/serialization/resources/tts/types/WebSocketTtsOutput.js +32 -6
- package/dist/serialization/resources/tts/types/WebSocketTtsRequest.js +32 -6
- package/dist/serialization/resources/tts/types/WordTimestamps.js +28 -2
- package/dist/serialization/resources/tts/types/index.js +46 -30
- package/dist/serialization/resources/voiceChanger/index.js +17 -1
- package/dist/serialization/resources/voiceChanger/types/OutputFormatContainer.js +28 -2
- package/dist/serialization/resources/voiceChanger/types/StreamingResponse.js +34 -8
- package/dist/serialization/resources/voiceChanger/types/index.js +18 -2
- package/dist/serialization/resources/voices/client/index.js +27 -1
- package/dist/serialization/resources/voices/client/list.js +29 -3
- package/dist/serialization/resources/voices/index.js +18 -2
- package/dist/serialization/resources/voices/types/BaseVoiceId.js +5 -2
- package/dist/serialization/resources/voices/types/CloneMode.js +28 -2
- package/dist/serialization/resources/voices/types/CreateVoiceRequest.js +34 -8
- package/dist/serialization/resources/voices/types/EmbeddingResponse.js +30 -4
- package/dist/serialization/resources/voices/types/EmbeddingSpecifier.js +32 -6
- package/dist/serialization/resources/voices/types/Gender.js +28 -2
- package/dist/serialization/resources/voices/types/IdSpecifier.js +32 -6
- package/dist/serialization/resources/voices/types/LocalizeDialect.d.ts +2 -1
- package/dist/serialization/resources/voices/types/LocalizeDialect.js +29 -2
- package/dist/serialization/resources/voices/types/LocalizeEnglishDialect.d.ts +10 -0
- package/dist/serialization/resources/voices/types/LocalizeEnglishDialect.js +31 -0
- package/dist/serialization/resources/voices/types/LocalizeTargetLanguage.js +28 -2
- package/dist/serialization/resources/voices/types/LocalizeVoiceRequest.js +36 -10
- package/dist/serialization/resources/voices/types/MixVoiceSpecifier.js +30 -4
- package/dist/serialization/resources/voices/types/MixVoicesRequest.js +30 -4
- package/dist/serialization/resources/voices/types/UpdateVoiceRequest.js +28 -2
- package/dist/serialization/resources/voices/types/Voice.js +36 -10
- package/dist/serialization/resources/voices/types/VoiceId.js +28 -2
- package/dist/serialization/resources/voices/types/VoiceMetadata.js +32 -6
- package/dist/serialization/resources/voices/types/Weight.js +28 -2
- package/dist/serialization/resources/voices/types/index.d.ts +1 -0
- package/dist/serialization/resources/voices/types/index.js +34 -17
- package/dist/version.d.ts +1 -1
- package/dist/version.js +4 -1
- package/dist/wrapper/Client.js +8 -4
- package/dist/wrapper/StreamingTTSClient.js +11 -4
- package/dist/wrapper/WebPlayer.js +7 -3
- package/dist/wrapper/Websocket.d.ts +7 -24
- package/dist/wrapper/Websocket.js +101 -71
- package/dist/wrapper/source.d.ts +5 -4
- package/dist/wrapper/source.js +12 -6
- package/dist/wrapper/utils.js +28 -13
- package/environments.js +4 -1
- package/errors/CartesiaError.js +5 -1
- package/errors/CartesiaTimeoutError.js +5 -1
- package/errors/index.js +7 -2
- package/index.js +34 -4
- package/package.json +2 -2
- package/reference.md +204 -0
- package/serialization/index.js +17 -1
- package/serialization/resources/apiStatus/index.js +17 -1
- package/serialization/resources/apiStatus/types/ApiInfo.js +28 -2
- package/serialization/resources/apiStatus/types/index.js +17 -1
- package/serialization/resources/datasets/index.d.ts +1 -0
- package/serialization/resources/datasets/index.js +17 -0
- package/serialization/resources/datasets/types/CreateDatasetRequest.d.ts +12 -0
- package/serialization/resources/datasets/types/CreateDatasetRequest.js +33 -0
- package/serialization/resources/datasets/types/Dataset.d.ts +14 -0
- package/serialization/resources/datasets/types/Dataset.js +35 -0
- package/serialization/resources/datasets/types/DatasetFile.d.ts +14 -0
- package/serialization/resources/datasets/types/DatasetFile.js +35 -0
- package/serialization/resources/datasets/types/FilePurpose.d.ts +10 -0
- package/serialization/resources/datasets/types/FilePurpose.js +31 -0
- package/serialization/resources/datasets/types/PaginatedDatasetFiles.d.ts +14 -0
- package/serialization/resources/datasets/types/PaginatedDatasetFiles.js +35 -0
- package/serialization/resources/datasets/types/PaginatedDatasets.d.ts +14 -0
- package/serialization/resources/datasets/types/PaginatedDatasets.js +35 -0
- package/serialization/resources/datasets/types/index.d.ts +6 -0
- package/serialization/resources/datasets/types/index.js +22 -0
- package/serialization/resources/embedding/index.js +17 -1
- package/serialization/resources/embedding/types/Embedding.js +28 -2
- package/serialization/resources/embedding/types/index.js +17 -1
- package/serialization/resources/index.d.ts +2 -0
- package/serialization/resources/index.js +41 -10
- package/serialization/resources/tts/index.js +17 -1
- package/serialization/resources/tts/types/CancelContextRequest.js +30 -4
- package/serialization/resources/tts/types/ContextId.js +28 -2
- package/serialization/resources/tts/types/Controls.js +32 -6
- package/serialization/resources/tts/types/Emotion.js +28 -2
- package/serialization/resources/tts/types/GenerationRequest.js +36 -10
- package/serialization/resources/tts/types/Mp3OutputFormat.js +28 -2
- package/serialization/resources/tts/types/NaturalSpecifier.js +28 -2
- package/serialization/resources/tts/types/NumericalSpecifier.js +28 -2
- package/serialization/resources/tts/types/OutputFormat.js +34 -8
- package/serialization/resources/tts/types/RawEncoding.js +28 -2
- package/serialization/resources/tts/types/RawOutputFormat.js +30 -4
- package/serialization/resources/tts/types/Speed.js +30 -4
- package/serialization/resources/tts/types/SupportedLanguage.js +28 -2
- package/serialization/resources/tts/types/TtsRequest.js +34 -8
- package/serialization/resources/tts/types/TtsRequestEmbeddingSpecifier.js +32 -6
- package/serialization/resources/tts/types/TtsRequestIdSpecifier.js +32 -6
- package/serialization/resources/tts/types/TtsRequestVoiceSpecifier.js +30 -4
- package/serialization/resources/tts/types/WavOutputFormat.js +29 -3
- package/serialization/resources/tts/types/WebSocketBaseResponse.js +30 -4
- package/serialization/resources/tts/types/WebSocketChunkResponse.js +30 -4
- package/serialization/resources/tts/types/WebSocketDoneResponse.js +29 -3
- package/serialization/resources/tts/types/WebSocketErrorResponse.js +30 -4
- package/serialization/resources/tts/types/WebSocketRawOutputFormat.js +30 -4
- package/serialization/resources/tts/types/WebSocketRequest.js +30 -4
- package/serialization/resources/tts/types/WebSocketResponse.js +36 -10
- package/serialization/resources/tts/types/WebSocketStreamOptions.js +28 -2
- package/serialization/resources/tts/types/WebSocketTimestampsResponse.js +32 -6
- package/serialization/resources/tts/types/WebSocketTtsOutput.js +32 -6
- package/serialization/resources/tts/types/WebSocketTtsRequest.js +32 -6
- package/serialization/resources/tts/types/WordTimestamps.js +28 -2
- package/serialization/resources/tts/types/index.js +46 -30
- package/serialization/resources/voiceChanger/index.js +17 -1
- package/serialization/resources/voiceChanger/types/OutputFormatContainer.js +28 -2
- package/serialization/resources/voiceChanger/types/StreamingResponse.js +34 -8
- package/serialization/resources/voiceChanger/types/index.js +18 -2
- package/serialization/resources/voices/client/index.js +27 -1
- package/serialization/resources/voices/client/list.js +29 -3
- package/serialization/resources/voices/index.js +18 -2
- package/serialization/resources/voices/types/BaseVoiceId.js +5 -2
- package/serialization/resources/voices/types/CloneMode.js +28 -2
- package/serialization/resources/voices/types/CreateVoiceRequest.js +34 -8
- package/serialization/resources/voices/types/EmbeddingResponse.js +30 -4
- package/serialization/resources/voices/types/EmbeddingSpecifier.js +32 -6
- package/serialization/resources/voices/types/Gender.js +28 -2
- package/serialization/resources/voices/types/IdSpecifier.js +32 -6
- package/serialization/resources/voices/types/LocalizeDialect.d.ts +2 -1
- package/serialization/resources/voices/types/LocalizeDialect.js +29 -2
- package/serialization/resources/voices/types/LocalizeEnglishDialect.d.ts +10 -0
- package/serialization/resources/voices/types/LocalizeEnglishDialect.js +31 -0
- package/serialization/resources/voices/types/LocalizeTargetLanguage.js +28 -2
- package/serialization/resources/voices/types/LocalizeVoiceRequest.js +36 -10
- package/serialization/resources/voices/types/MixVoiceSpecifier.js +30 -4
- package/serialization/resources/voices/types/MixVoicesRequest.js +30 -4
- package/serialization/resources/voices/types/UpdateVoiceRequest.js +28 -2
- package/serialization/resources/voices/types/Voice.js +36 -10
- package/serialization/resources/voices/types/VoiceId.js +28 -2
- package/serialization/resources/voices/types/VoiceMetadata.js +32 -6
- package/serialization/resources/voices/types/Weight.js +28 -2
- package/serialization/resources/voices/types/index.d.ts +1 -0
- package/serialization/resources/voices/types/index.js +34 -17
- package/version.d.ts +1 -1
- package/version.js +4 -1
- package/wrapper/Client.js +8 -4
- package/wrapper/StreamingTTSClient.js +11 -4
- package/wrapper/WebPlayer.js +7 -3
- package/wrapper/Websocket.d.ts +7 -24
- package/wrapper/Websocket.js +101 -71
- package/wrapper/source.d.ts +5 -4
- package/wrapper/source.js +12 -6
- package/wrapper/utils.js +28 -13
|
@@ -1,5 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* This file was auto-generated by Fern from our API Definition.
|
|
3
4
|
*/
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
+
__setModuleDefault(result, mod);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.VoiceId = void 0;
|
|
30
|
+
const core = __importStar(require("../../../../core"));
|
|
31
|
+
exports.VoiceId = core.serialization.string();
|
|
@@ -1,15 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* This file was auto-generated by Fern from our API Definition.
|
|
3
4
|
*/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
+
__setModuleDefault(result, mod);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.VoiceMetadata = void 0;
|
|
30
|
+
const core = __importStar(require("../../../../core"));
|
|
31
|
+
const VoiceId_1 = require("./VoiceId");
|
|
32
|
+
const SupportedLanguage_1 = require("../../tts/types/SupportedLanguage");
|
|
33
|
+
exports.VoiceMetadata = core.serialization.object({
|
|
34
|
+
id: VoiceId_1.VoiceId,
|
|
9
35
|
userId: core.serialization.property("user_id", core.serialization.string()),
|
|
10
36
|
isPublic: core.serialization.property("is_public", core.serialization.boolean()),
|
|
11
37
|
name: core.serialization.string(),
|
|
12
38
|
description: core.serialization.string(),
|
|
13
39
|
createdAt: core.serialization.property("created_at", core.serialization.date()),
|
|
14
|
-
language: SupportedLanguage,
|
|
40
|
+
language: SupportedLanguage_1.SupportedLanguage,
|
|
15
41
|
});
|
|
@@ -1,5 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* This file was auto-generated by Fern from our API Definition.
|
|
3
4
|
*/
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
+
__setModuleDefault(result, mod);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.Weight = void 0;
|
|
30
|
+
const core = __importStar(require("../../../../core"));
|
|
31
|
+
exports.Weight = core.serialization.number();
|
|
@@ -5,6 +5,7 @@ export * from "./VoiceMetadata";
|
|
|
5
5
|
export * from "./CreateVoiceRequest";
|
|
6
6
|
export * from "./UpdateVoiceRequest";
|
|
7
7
|
export * from "./LocalizeTargetLanguage";
|
|
8
|
+
export * from "./LocalizeEnglishDialect";
|
|
8
9
|
export * from "./LocalizeDialect";
|
|
9
10
|
export * from "./Gender";
|
|
10
11
|
export * from "./LocalizeVoiceRequest";
|
|
@@ -1,17 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./VoiceId"), exports);
|
|
18
|
+
__exportStar(require("./BaseVoiceId"), exports);
|
|
19
|
+
__exportStar(require("./Voice"), exports);
|
|
20
|
+
__exportStar(require("./VoiceMetadata"), exports);
|
|
21
|
+
__exportStar(require("./CreateVoiceRequest"), exports);
|
|
22
|
+
__exportStar(require("./UpdateVoiceRequest"), exports);
|
|
23
|
+
__exportStar(require("./LocalizeTargetLanguage"), exports);
|
|
24
|
+
__exportStar(require("./LocalizeEnglishDialect"), exports);
|
|
25
|
+
__exportStar(require("./LocalizeDialect"), exports);
|
|
26
|
+
__exportStar(require("./Gender"), exports);
|
|
27
|
+
__exportStar(require("./LocalizeVoiceRequest"), exports);
|
|
28
|
+
__exportStar(require("./EmbeddingResponse"), exports);
|
|
29
|
+
__exportStar(require("./MixVoicesRequest"), exports);
|
|
30
|
+
__exportStar(require("./Weight"), exports);
|
|
31
|
+
__exportStar(require("./IdSpecifier"), exports);
|
|
32
|
+
__exportStar(require("./EmbeddingSpecifier"), exports);
|
|
33
|
+
__exportStar(require("./MixVoiceSpecifier"), exports);
|
|
34
|
+
__exportStar(require("./CloneMode"), exports);
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "2.0.
|
|
1
|
+
export declare const SDK_VERSION = "2.0.4-alpha0";
|
package/dist/version.js
CHANGED
package/dist/wrapper/Client.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CartesiaClient = void 0;
|
|
4
|
+
const Client_1 = require("../Client");
|
|
5
|
+
const StreamingTTSClient_1 = require("./StreamingTTSClient");
|
|
6
|
+
class CartesiaClient extends Client_1.CartesiaClient {
|
|
4
7
|
get tts() {
|
|
5
8
|
var _a;
|
|
6
|
-
return ((_a = this._tts) !== null && _a !== void 0 ? _a : (this._tts = new StreamingTTSClient(this._options)));
|
|
9
|
+
return ((_a = this._tts) !== null && _a !== void 0 ? _a : (this._tts = new StreamingTTSClient_1.StreamingTTSClient(this._options)));
|
|
7
10
|
}
|
|
8
11
|
}
|
|
12
|
+
exports.CartesiaClient = CartesiaClient;
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.StreamingTTSClient = void 0;
|
|
7
|
+
const Client_1 = require("../api/resources/tts/client/Client");
|
|
8
|
+
const Websocket_1 = __importDefault(require("./Websocket"));
|
|
9
|
+
class StreamingTTSClient extends Client_1.Tts {
|
|
4
10
|
constructor(options = {}) {
|
|
5
11
|
super(options);
|
|
6
12
|
}
|
|
@@ -11,6 +17,7 @@ export class StreamingTTSClient extends Tts {
|
|
|
11
17
|
* @returns A WebSocket client configured for streaming TTS.
|
|
12
18
|
*/
|
|
13
19
|
websocket({ sampleRate, container, encoding, }) {
|
|
14
|
-
return new
|
|
20
|
+
return new Websocket_1.default({ sampleRate, container, encoding }, Object.assign({ cartesiaVersion: "2024-06-10" }, this._options));
|
|
15
21
|
}
|
|
16
22
|
}
|
|
23
|
+
exports.StreamingTTSClient = StreamingTTSClient;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -19,8 +20,10 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
19
20
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
20
21
|
};
|
|
21
22
|
var _WebPlayer_instances, _WebPlayer_context, _WebPlayer_startNextPlaybackAt, _WebPlayer_bufferDuration, _WebPlayer_playBuffer;
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.WebPlayer = void 0;
|
|
25
|
+
const utils_1 = require("./utils");
|
|
26
|
+
class WebPlayer {
|
|
24
27
|
/**
|
|
25
28
|
* Create a new Player.
|
|
26
29
|
*
|
|
@@ -121,6 +124,7 @@ export class WebPlayer {
|
|
|
121
124
|
});
|
|
122
125
|
}
|
|
123
126
|
}
|
|
127
|
+
exports.WebPlayer = WebPlayer;
|
|
124
128
|
_WebPlayer_context = new WeakMap(), _WebPlayer_startNextPlaybackAt = new WeakMap(), _WebPlayer_bufferDuration = new WeakMap(), _WebPlayer_instances = new WeakSet(), _WebPlayer_playBuffer = function _WebPlayer_playBuffer(buf, sampleRate) {
|
|
125
129
|
return __awaiter(this, void 0, void 0, function* () {
|
|
126
130
|
if (!__classPrivateFieldGet(this, _WebPlayer_context, "f")) {
|
|
@@ -132,6 +136,6 @@ _WebPlayer_context = new WeakMap(), _WebPlayer_startNextPlaybackAt = new WeakMap
|
|
|
132
136
|
const startAt = __classPrivateFieldGet(this, _WebPlayer_startNextPlaybackAt, "f");
|
|
133
137
|
const duration = buf.length / sampleRate;
|
|
134
138
|
__classPrivateFieldSet(this, _WebPlayer_startNextPlaybackAt, duration + Math.max(__classPrivateFieldGet(this, _WebPlayer_context, "f").currentTime, __classPrivateFieldGet(this, _WebPlayer_startNextPlaybackAt, "f")), "f");
|
|
135
|
-
yield playAudioBuffer(buf, __classPrivateFieldGet(this, _WebPlayer_context, "f"), startAt, sampleRate);
|
|
139
|
+
yield (0, utils_1.playAudioBuffer)(buf, __classPrivateFieldGet(this, _WebPlayer_context, "f"), startAt, sampleRate);
|
|
136
140
|
});
|
|
137
141
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReconnectingWebSocket, Options } from "../core/websocket";
|
|
2
2
|
import type { WebSocketStreamOptions, WebSocketTtsRequest, WordTimestamps } from "../api";
|
|
3
3
|
import { ConnectionEventData, WebSocketOptions, EmitteryCallbacks } from "./utils";
|
|
4
|
-
import { Tts } from "api/resources/tts/client/Client";
|
|
4
|
+
import { Tts } from "../api/resources/tts/client/Client";
|
|
5
5
|
import Source from "./source";
|
|
6
6
|
export default class Websocket {
|
|
7
7
|
#private;
|
|
@@ -17,31 +17,14 @@ export default class Websocket {
|
|
|
17
17
|
* If set to `0`, the stream will not time out.
|
|
18
18
|
* @returns A Source object that can be passed to a Player to play the audio.
|
|
19
19
|
* @returns An Emittery instance that emits messages from the WebSocket.
|
|
20
|
-
* @returns An abort function that can be called to cancel the stream.
|
|
21
20
|
*/
|
|
22
|
-
send(inputs: WebSocketTtsRequest, { timeout }?: WebSocketStreamOptions): {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
};
|
|
27
|
-
on: <Name extends "timestamps" | "message" | keyof import("emittery").OmnipresentEventData>(eventName: Name | readonly Name[], listener: (eventData: ({
|
|
28
|
-
message: string;
|
|
29
|
-
timestamps: WordTimestamps;
|
|
30
|
-
} & import("emittery").OmnipresentEventData)[Name]) => void | Promise<void>) => import("emittery").UnsubscribeFunction;
|
|
31
|
-
off: <Name_1 extends "timestamps" | "message" | keyof import("emittery").OmnipresentEventData>(eventName: Name_1 | readonly Name_1[], listener: (eventData: ({
|
|
32
|
-
message: string;
|
|
33
|
-
timestamps: WordTimestamps;
|
|
34
|
-
} & import("emittery").OmnipresentEventData)[Name_1]) => void | Promise<void>) => void;
|
|
35
|
-
once: <Name_2 extends "timestamps" | "message" | keyof import("emittery").OmnipresentEventData>(eventName: Name_2 | readonly Name_2[]) => import("emittery").EmitteryOncePromise<({
|
|
36
|
-
message: string;
|
|
37
|
-
timestamps: WordTimestamps;
|
|
38
|
-
} & import("emittery").OmnipresentEventData)[Name_2]>;
|
|
39
|
-
events: <Name_3 extends "timestamps" | "message">(eventName: Name_3 | readonly Name_3[]) => AsyncIterableIterator<{
|
|
40
|
-
message: string;
|
|
41
|
-
timestamps: WordTimestamps;
|
|
42
|
-
}[Name_3]>;
|
|
21
|
+
send(inputs: WebSocketTtsRequest, { timeout }?: WebSocketStreamOptions): Promise<EmitteryCallbacks<{
|
|
22
|
+
message: string;
|
|
23
|
+
timestamps: WordTimestamps;
|
|
24
|
+
}> & {
|
|
43
25
|
source: Source;
|
|
44
|
-
|
|
26
|
+
stop: unknown;
|
|
27
|
+
}>;
|
|
45
28
|
continue(inputs: WebSocketTtsRequest): void;
|
|
46
29
|
/**
|
|
47
30
|
* Authenticate and connect to a Cartesia streaming WebSocket.
|
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
1
25
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
26
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
27
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -18,17 +42,21 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
18
42
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
19
43
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
20
44
|
};
|
|
45
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
46
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
47
|
+
};
|
|
21
48
|
var _Websocket_instances, _Websocket_isConnected, _Websocket_sampleRate, _Websocket_container, _Websocket_encoding, _Websocket_generateId;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
const core = __importStar(require("../core"));
|
|
51
|
+
const environments = __importStar(require("../environments"));
|
|
52
|
+
const serializers = __importStar(require("../serialization"));
|
|
53
|
+
const emittery_1 = __importDefault(require("emittery"));
|
|
54
|
+
const human_id_1 = require("human-id");
|
|
55
|
+
const websocket_1 = require("../core/websocket");
|
|
56
|
+
const utils_1 = require("./utils");
|
|
57
|
+
const source_1 = __importDefault(require("./source"));
|
|
58
|
+
const qs_1 = __importDefault(require("qs"));
|
|
59
|
+
class Websocket {
|
|
32
60
|
constructor({ sampleRate, container, encoding }, options) {
|
|
33
61
|
this.options = options;
|
|
34
62
|
_Websocket_instances.add(this);
|
|
@@ -49,69 +77,70 @@ export default class Websocket {
|
|
|
49
77
|
* If set to `0`, the stream will not time out.
|
|
50
78
|
* @returns A Source object that can be passed to a Player to play the audio.
|
|
51
79
|
* @returns An Emittery instance that emits messages from the WebSocket.
|
|
52
|
-
* @returns An abort function that can be called to cancel the stream.
|
|
53
80
|
*/
|
|
54
81
|
send(inputs, { timeout = 0 } = {}) {
|
|
55
82
|
var _a, _b, _c, _d;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
if (!inputs.contextId) {
|
|
60
|
-
inputs.contextId = __classPrivateFieldGet(this, _Websocket_instances, "m", _Websocket_generateId).call(this);
|
|
61
|
-
}
|
|
62
|
-
if (!inputs.outputFormat) {
|
|
63
|
-
inputs.outputFormat = resolveOutputFormat(__classPrivateFieldGet(this, _Websocket_container, "f"), __classPrivateFieldGet(this, _Websocket_encoding, "f"), __classPrivateFieldGet(this, _Websocket_sampleRate, "f"));
|
|
64
|
-
}
|
|
65
|
-
(_a = this.socket) === null || _a === void 0 ? void 0 : _a.send(JSON.stringify(serializers.WebSocketTtsRequest.jsonOrThrow(inputs, { unrecognizedObjectKeys: "strip" })));
|
|
66
|
-
const emitter = new Emittery();
|
|
67
|
-
const source = new Source({
|
|
68
|
-
sampleRate: __classPrivateFieldGet(this, _Websocket_sampleRate, "f"),
|
|
69
|
-
encoding: __classPrivateFieldGet(this, _Websocket_encoding, "f"),
|
|
70
|
-
container: __classPrivateFieldGet(this, _Websocket_container, "f"),
|
|
71
|
-
});
|
|
72
|
-
// Used to signal that the stream is complete, either because the
|
|
73
|
-
// WebSocket has closed, or because the stream has finished.
|
|
74
|
-
const streamCompleteController = new AbortController();
|
|
75
|
-
// Set a timeout.
|
|
76
|
-
let timeoutId = null;
|
|
77
|
-
if (timeout > 0) {
|
|
78
|
-
timeoutId = setTimeout(streamCompleteController.abort, timeout);
|
|
79
|
-
}
|
|
80
|
-
const handleMessage = createMessageHandlerForContextId(inputs.contextId, ({ chunk, message, data }) => __awaiter(this, void 0, void 0, function* () {
|
|
81
|
-
emitter.emit("message", message);
|
|
82
|
-
if (data.type === "timestamps" && data.wordTimestamps) {
|
|
83
|
-
emitter.emit("timestamps", data.wordTimestamps);
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
if (isSentinel(chunk)) {
|
|
87
|
-
yield source.close();
|
|
88
|
-
streamCompleteController.abort();
|
|
89
|
-
return;
|
|
83
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
+
if (!__classPrivateFieldGet(this, _Websocket_isConnected, "f")) {
|
|
85
|
+
throw new Error("Not connected to WebSocket. Call .connect() first.");
|
|
90
86
|
}
|
|
91
|
-
if (
|
|
92
|
-
|
|
93
|
-
timeoutId = setTimeout(streamCompleteController.abort, timeout);
|
|
87
|
+
if (!inputs.contextId) {
|
|
88
|
+
inputs.contextId = __classPrivateFieldGet(this, _Websocket_instances, "m", _Websocket_generateId).call(this);
|
|
94
89
|
}
|
|
95
|
-
if (!
|
|
96
|
-
|
|
90
|
+
if (!inputs.outputFormat) {
|
|
91
|
+
inputs.outputFormat = (0, utils_1.resolveOutputFormat)(__classPrivateFieldGet(this, _Websocket_container, "f"), __classPrivateFieldGet(this, _Websocket_encoding, "f"), __classPrivateFieldGet(this, _Websocket_sampleRate, "f"));
|
|
97
92
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
93
|
+
(_a = this.socket) === null || _a === void 0 ? void 0 : _a.send(JSON.stringify(serializers.WebSocketTtsRequest.jsonOrThrow(inputs, { unrecognizedObjectKeys: "strip" })));
|
|
94
|
+
const emitter = new emittery_1.default();
|
|
95
|
+
const source = new source_1.default({
|
|
96
|
+
sampleRate: __classPrivateFieldGet(this, _Websocket_sampleRate, "f"),
|
|
97
|
+
encoding: __classPrivateFieldGet(this, _Websocket_encoding, "f"),
|
|
98
|
+
container: __classPrivateFieldGet(this, _Websocket_container, "f"),
|
|
99
|
+
});
|
|
100
|
+
// Used to signal that the stream is complete, either because the
|
|
101
|
+
// WebSocket has closed, or because the stream has finished.
|
|
102
|
+
const streamCompleteController = new AbortController();
|
|
103
|
+
// Set a timeout.
|
|
104
|
+
let timeoutId = null;
|
|
105
|
+
if (timeout > 0) {
|
|
106
|
+
timeoutId = setTimeout(streamCompleteController.abort, timeout);
|
|
111
107
|
}
|
|
112
|
-
|
|
108
|
+
const handleMessage = (0, utils_1.createMessageHandlerForContextId)(inputs.contextId, ({ chunk, message, data }) => __awaiter(this, void 0, void 0, function* () {
|
|
109
|
+
emitter.emit("message", message);
|
|
110
|
+
if (data.type === "timestamps" && data.wordTimestamps) {
|
|
111
|
+
emitter.emit("timestamps", data.wordTimestamps);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
if ((0, utils_1.isSentinel)(chunk)) {
|
|
115
|
+
yield source.close();
|
|
116
|
+
streamCompleteController.abort();
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
if (timeoutId) {
|
|
120
|
+
clearTimeout(timeoutId);
|
|
121
|
+
timeoutId = setTimeout(streamCompleteController.abort, timeout);
|
|
122
|
+
}
|
|
123
|
+
if (!chunk) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
yield source.enqueue((0, utils_1.base64ToArray)([chunk], __classPrivateFieldGet(this, _Websocket_encoding, "f")));
|
|
127
|
+
}));
|
|
128
|
+
(_b = this.socket) === null || _b === void 0 ? void 0 : _b.addEventListener("message", handleMessage);
|
|
129
|
+
(_c = this.socket) === null || _c === void 0 ? void 0 : _c.addEventListener("close", () => {
|
|
130
|
+
streamCompleteController.abort();
|
|
131
|
+
});
|
|
132
|
+
(_d = this.socket) === null || _d === void 0 ? void 0 : _d.addEventListener("error", () => {
|
|
133
|
+
streamCompleteController.abort();
|
|
134
|
+
});
|
|
135
|
+
streamCompleteController.signal.addEventListener("abort", () => {
|
|
136
|
+
source.close();
|
|
137
|
+
if (timeoutId) {
|
|
138
|
+
clearTimeout(timeoutId);
|
|
139
|
+
}
|
|
140
|
+
emitter.clearListeners();
|
|
141
|
+
});
|
|
142
|
+
return Object.assign(Object.assign({ source }, (0, utils_1.getEmitteryCallbacks)(emitter)), { stop: streamCompleteController.abort.bind(streamCompleteController) });
|
|
113
143
|
});
|
|
114
|
-
return Object.assign(Object.assign({ source }, getEmitteryCallbacks(emitter)), { stop: streamCompleteController.abort.bind(streamCompleteController) });
|
|
115
144
|
}
|
|
116
145
|
continue(inputs) {
|
|
117
146
|
var _a;
|
|
@@ -122,7 +151,7 @@ export default class Websocket {
|
|
|
122
151
|
throw new Error("context_id is required to continue a context.");
|
|
123
152
|
}
|
|
124
153
|
if (!inputs.outputFormat) {
|
|
125
|
-
inputs.outputFormat = resolveOutputFormat(__classPrivateFieldGet(this, _Websocket_container, "f"), __classPrivateFieldGet(this, _Websocket_encoding, "f"), __classPrivateFieldGet(this, _Websocket_sampleRate, "f"));
|
|
154
|
+
inputs.outputFormat = (0, utils_1.resolveOutputFormat)(__classPrivateFieldGet(this, _Websocket_container, "f"), __classPrivateFieldGet(this, _Websocket_encoding, "f"), __classPrivateFieldGet(this, _Websocket_sampleRate, "f"));
|
|
126
155
|
}
|
|
127
156
|
(_a = this.socket) === null || _a === void 0 ? void 0 : _a.send(JSON.stringify(Object.assign({ continue: true }, serializers.WebSocketTtsRequest.jsonOrThrow(inputs, { unrecognizedObjectKeys: "strip" }))));
|
|
128
157
|
}
|
|
@@ -137,15 +166,15 @@ export default class Websocket {
|
|
|
137
166
|
if (__classPrivateFieldGet(this, _Websocket_isConnected, "f")) {
|
|
138
167
|
throw new Error("WebSocket is already connected.");
|
|
139
168
|
}
|
|
140
|
-
const emitter = new
|
|
141
|
-
this.socket = new ReconnectingWebSocket(() => __awaiter(this, void 0, void 0, function* () {
|
|
169
|
+
const emitter = new emittery_1.default();
|
|
170
|
+
this.socket = new websocket_1.ReconnectingWebSocket(() => __awaiter(this, void 0, void 0, function* () {
|
|
142
171
|
var _a;
|
|
143
172
|
const baseUrl = ((_a = (yield core.Supplier.get(this.options.environment))) !== null && _a !== void 0 ? _a : environments.CartesiaEnvironment.Production).replace(/^https?:\/\//, "");
|
|
144
173
|
const params = {
|
|
145
174
|
api_key: this.options.apiKey,
|
|
146
175
|
cartesia_version: this.options.cartesiaVersion,
|
|
147
176
|
};
|
|
148
|
-
return `wss://${baseUrl}/tts/websocket${
|
|
177
|
+
return `wss://${baseUrl}/tts/websocket${qs_1.default.stringify(params, { addQueryPrefix: true })}`;
|
|
149
178
|
}), undefined, options);
|
|
150
179
|
this.socket.reconnect();
|
|
151
180
|
this.socket.onopen = () => {
|
|
@@ -159,7 +188,7 @@ export default class Websocket {
|
|
|
159
188
|
return new Promise((resolve, reject) => {
|
|
160
189
|
var _a, _b, _c;
|
|
161
190
|
(_a = this.socket) === null || _a === void 0 ? void 0 : _a.addEventListener("open", () => {
|
|
162
|
-
resolve(getEmitteryCallbacks(emitter));
|
|
191
|
+
resolve((0, utils_1.getEmitteryCallbacks)(emitter));
|
|
163
192
|
});
|
|
164
193
|
const aborter = new AbortController();
|
|
165
194
|
(_b = this.socket) === null || _b === void 0 ? void 0 : _b.addEventListener("error", () => {
|
|
@@ -181,8 +210,9 @@ export default class Websocket {
|
|
|
181
210
|
(_a = this.socket) === null || _a === void 0 ? void 0 : _a.close();
|
|
182
211
|
}
|
|
183
212
|
}
|
|
213
|
+
exports.default = Websocket;
|
|
184
214
|
_Websocket_isConnected = new WeakMap(), _Websocket_sampleRate = new WeakMap(), _Websocket_container = new WeakMap(), _Websocket_encoding = new WeakMap(), _Websocket_instances = new WeakSet(), _Websocket_generateId = function _Websocket_generateId() {
|
|
185
|
-
return humanId({
|
|
215
|
+
return (0, human_id_1.humanId)({
|
|
186
216
|
separator: "-",
|
|
187
217
|
capitalize: false,
|
|
188
218
|
});
|
package/dist/wrapper/source.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import Emittery from "emittery";
|
|
1
2
|
import { RawEncoding } from "../api";
|
|
2
3
|
import { SourceEventData, TypedArray } from "./utils";
|
|
3
4
|
export default class Source {
|
|
4
5
|
#private;
|
|
5
|
-
on: <
|
|
6
|
-
once: <
|
|
7
|
-
events: <
|
|
8
|
-
off: <
|
|
6
|
+
on: Emittery<SourceEventData>["on"];
|
|
7
|
+
once: Emittery<SourceEventData>["once"];
|
|
8
|
+
events: Emittery<SourceEventData>["events"];
|
|
9
|
+
off: Emittery<SourceEventData>["off"];
|
|
9
10
|
/**
|
|
10
11
|
* Create a new Source.
|
|
11
12
|
*
|
package/dist/wrapper/source.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -18,10 +19,14 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
18
19
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
19
20
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
20
21
|
};
|
|
22
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
|
+
};
|
|
21
25
|
var _Source_instances, _Source_emitter, _Source_buffer, _Source_readIndex, _Source_writeIndex, _Source_closed, _Source_sampleRate, _Source_encoding, _Source_container, _Source_createBuffer;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
const emittery_1 = __importDefault(require("emittery"));
|
|
28
|
+
const utils_1 = require("./utils");
|
|
29
|
+
class Source {
|
|
25
30
|
/**
|
|
26
31
|
* Create a new Source.
|
|
27
32
|
*
|
|
@@ -30,7 +35,7 @@ export default class Source {
|
|
|
30
35
|
*/
|
|
31
36
|
constructor({ sampleRate, encoding, container }) {
|
|
32
37
|
_Source_instances.add(this);
|
|
33
|
-
_Source_emitter.set(this, new
|
|
38
|
+
_Source_emitter.set(this, new emittery_1.default());
|
|
34
39
|
_Source_buffer.set(this, void 0);
|
|
35
40
|
_Source_readIndex.set(this, 0);
|
|
36
41
|
_Source_writeIndex.set(this, 0);
|
|
@@ -41,7 +46,7 @@ export default class Source {
|
|
|
41
46
|
this.on = __classPrivateFieldGet(this, _Source_emitter, "f").on.bind(__classPrivateFieldGet(this, _Source_emitter, "f"));
|
|
42
47
|
this.once = __classPrivateFieldGet(this, _Source_emitter, "f").once.bind(__classPrivateFieldGet(this, _Source_emitter, "f"));
|
|
43
48
|
this.events = __classPrivateFieldGet(this, _Source_emitter, "f").events.bind(__classPrivateFieldGet(this, _Source_emitter, "f"));
|
|
44
|
-
this.off = __classPrivateFieldGet(this, _Source_emitter, "f").off.bind(__classPrivateFieldGet(this, _Source_emitter, "f"));
|
|
49
|
+
this.off = __classPrivateFieldGet(this, _Source_emitter, "f").off.bind(__classPrivateFieldGet(this, _Source_emitter, "f").off);
|
|
45
50
|
__classPrivateFieldSet(this, _Source_sampleRate, sampleRate, "f");
|
|
46
51
|
__classPrivateFieldSet(this, _Source_encoding, encoding, "f");
|
|
47
52
|
__classPrivateFieldSet(this, _Source_container, container, "f");
|
|
@@ -167,7 +172,8 @@ export default class Source {
|
|
|
167
172
|
});
|
|
168
173
|
}
|
|
169
174
|
}
|
|
175
|
+
exports.default = Source;
|
|
170
176
|
_Source_emitter = new WeakMap(), _Source_buffer = new WeakMap(), _Source_readIndex = new WeakMap(), _Source_writeIndex = new WeakMap(), _Source_closed = new WeakMap(), _Source_sampleRate = new WeakMap(), _Source_encoding = new WeakMap(), _Source_container = new WeakMap(), _Source_instances = new WeakSet(), _Source_createBuffer = function _Source_createBuffer(size) {
|
|
171
|
-
const { arrayType: ArrayType } = ENCODING_MAP[__classPrivateFieldGet(this, _Source_encoding, "f")];
|
|
177
|
+
const { arrayType: ArrayType } = utils_1.ENCODING_MAP[__classPrivateFieldGet(this, _Source_encoding, "f")];
|
|
172
178
|
return new ArrayType(size);
|
|
173
179
|
};
|