ugcinc 4.23.0 → 4.24.0
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/README.md +21 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +6 -1
- package/dist/media-analysis.d.ts +1691 -226
- package/dist/media-analysis.js +21 -2
- package/dist/media.d.ts +3 -1
- package/dist/media.js +6 -0
- package/dist/tools/media.js +2 -0
- package/dist/types.d.ts +1 -1
- package/package.json +1 -1
package/dist/media-analysis.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mediaAnalysisResultSchema = exports.audioTranscriptResultSchema = exports.audioLevelsResultSchema = exports.measureAudioLevelsSchema = exports.transcribeAudioSchema = exports.videoTextResultSchema = exports.imageTextResultSchema = exports.textLineSchema = exports.textRegionSchema = exports.readVideoTextSchema = exports.readImageTextSchema = exports.scenesResultSchema = exports.framesResultSchema = exports.analysisSourceSchema = exports.mediaAnalysisStatusSchema = exports.extractFramesSchema = exports.detectScenesSchema = void 0;
|
|
3
|
+
exports.mediaAnalysisResultSchema = exports.measureLayoutResultSchema = exports.sampleColorsResultSchema = exports.measureLayoutSchema = exports.sampleColorsSchema = exports.binaryMaskSchema = exports.audioTranscriptResultSchema = exports.audioLevelsResultSchema = exports.measureAudioLevelsSchema = exports.transcribeAudioSchema = exports.videoTextResultSchema = exports.imageTextResultSchema = exports.textLineSchema = exports.textRegionSchema = exports.readVideoTextSchema = exports.readImageTextSchema = exports.scenesResultSchema = exports.framesResultSchema = exports.analysisSourceSchema = exports.mediaAnalysisStatusSchema = exports.extractFramesSchema = exports.detectScenesSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const videoUrl = zod_1.z.string().url().max(8192).refine(value => {
|
|
6
6
|
const url = new URL(value);
|
|
@@ -87,4 +87,23 @@ exports.audioTranscriptResultSchema = zod_1.z.object({ version: zod_1.z.literal(
|
|
|
87
87
|
segments: zod_1.z.array(zod_1.z.object({ index: zod_1.z.number().int(), text: zod_1.z.string(), startMs: zod_1.z.number().finite(), endMs: zod_1.z.number().finite(), timing: zod_1.z.literal('estimated'), avgLogProbability: zod_1.z.number(), noSpeechProbability: zod_1.z.number(), words: zod_1.z.array(estimatedWord) })),
|
|
88
88
|
language: zod_1.z.string().nullable(), languageProbability: zod_1.z.number().nullable(), segmentTiming: zod_1.z.enum(['estimated', 'unavailable']), wordTiming: zod_1.z.enum(['estimated', 'unavailable']), speakerLabels: zod_1.z.literal('unavailable'),
|
|
89
89
|
channelPolicy: zod_1.z.string(), warnings: zod_1.z.array(zod_1.z.string()), audioPreviewUrl: zod_1.z.string().url().optional(), manifestUrl: zod_1.z.string().url() });
|
|
90
|
-
|
|
90
|
+
const imageBox = zod_1.z.object({ x: zod_1.z.number().finite().min(0).max(4096), y: zod_1.z.number().finite().min(0).max(4096), width: zod_1.z.number().finite().positive().max(4096), height: zod_1.z.number().finite().positive().max(4096) }).strict().refine(b => b.x + b.width <= 4096 && b.y + b.height <= 4096, 'Box exceeds image limit');
|
|
91
|
+
exports.binaryMaskSchema = zod_1.z.object({ width: zod_1.z.number().int().min(1).max(4096), height: zod_1.z.number().int().min(1).max(4096), counts: zod_1.z.array(zod_1.z.number().int().min(0).max(16777216)).min(1).max(100000) }).strict().refine(m => m.counts.reduce((s, n) => s + n, 0) === m.width * m.height && m.counts.every((n, i) => i === 0 || n > 0), 'Row-major runs must sum to width*height and alternate background/foreground; only first may be zero');
|
|
92
|
+
exports.sampleColorsSchema = zod_1.z.object({ url: videoUrl,
|
|
93
|
+
point: zod_1.z.object({ x: zod_1.z.number().int().min(0).max(4095), y: zod_1.z.number().int().min(0).max(4095) }).strict().optional(),
|
|
94
|
+
box: imageBox.optional(), mask: exports.binaryMaskSchema.optional(), maxColors: zod_1.z.number().int().min(1).max(32).default(8),
|
|
95
|
+
}).strict().refine(v => [v.point, v.box, v.mask].filter(x => x !== undefined).length <= 1, 'Provide at most one point, box or mask');
|
|
96
|
+
const layoutElement = zod_1.z.object({ id: zod_1.z.string().min(1).max(80), box: imageBox.optional(), mask: exports.binaryMaskSchema.optional() }).strict().refine(v => Boolean(v.box) !== Boolean(v.mask), 'Provide box or mask exclusively');
|
|
97
|
+
exports.measureLayoutSchema = zod_1.z.object({ url: videoUrl, elements: zod_1.z.array(layoutElement).min(1).max(32) }).strict().refine(v => new Set(v.elements.map(e => e.id)).size === v.elements.length && v.elements.reduce((s, e) => s + (e.mask?.counts.length ?? 0), 0) <= 100000, 'IDs must be unique; total mask runs at most 100000');
|
|
98
|
+
const visualSource = zod_1.z.object({ encodedWidth: zod_1.z.number(), encodedHeight: zod_1.z.number(), displayWidth: zod_1.z.number(), displayHeight: zod_1.z.number(), exifOrientation: zod_1.z.number(), colorSpace: zod_1.z.literal('sRGB'), colorPolicy: zod_1.z.enum(['embedded-ICC-to-sRGB-relative-colorimetric', 'untagged-assumed-sRGB']), alphaPolicy: zod_1.z.literal('straight-alpha-no-background-composite'), sha256: zod_1.z.string(), bytes: zod_1.z.number() });
|
|
99
|
+
const finiteNumber = zod_1.z.number().finite();
|
|
100
|
+
const edges = zod_1.z.object({ left: finiteNumber, top: finiteNumber, right: finiteNumber, bottom: finiteNumber });
|
|
101
|
+
exports.sampleColorsResultSchema = zod_1.z.object({ version: zod_1.z.literal(1), operation: zod_1.z.literal('sample_colors'), source: visualSource,
|
|
102
|
+
point: zod_1.z.object({ x: finiteNumber, y: finiteNumber, rgba: zod_1.z.array(zod_1.z.number().int().min(0).max(255)).length(4) }).nullable(), selectionBox: boxSchema.nullable(),
|
|
103
|
+
selectedPixelCount: time, visiblePixelCount: time, alphaWeight: time, palette: zod_1.z.array(zod_1.z.object({ rgb: zod_1.z.array(zod_1.z.number().int().min(0).max(255)).length(3), hex: zod_1.z.string(), proportion: zod_1.z.number().min(0).max(1) })), otherProportion: zod_1.z.number().min(0).max(1),
|
|
104
|
+
method: zod_1.z.enum(['exact-observed-colors', '5-bit-sRGB-bins-alpha-weighted-mean']), warnings: zod_1.z.array(zod_1.z.string()), previewUrl: zod_1.z.string().url(), manifestUrl: zod_1.z.string().url() });
|
|
105
|
+
exports.measureLayoutResultSchema = zod_1.z.object({ version: zod_1.z.literal(1), operation: zod_1.z.literal('measure_layout'), source: visualSource, coordinates: zod_1.z.literal('display-oriented-source-pixels'),
|
|
106
|
+
elements: zod_1.z.array(zod_1.z.object({ id: zod_1.z.string(), geometry: zod_1.z.enum(['box', 'mask']), box: boxSchema.nullable(), normalizedBox: boxSchema.nullable(), boxArea: time, visibleArea: time.nullable(), visibleFractionOfCanvas: time.nullable(), boxCenter: pointSchema.nullable(), visibleCentroid: pointSchema.nullable(), margins: edges.nullable() })),
|
|
107
|
+
pairs: zod_1.z.array(zod_1.z.object({ a: zod_1.z.string(), b: zod_1.z.string(), boxIntersectionArea: time, boxIoU: time.nullable(), visibleIntersectionArea: time.nullable(), visibleIoU: time.nullable(), axisGaps: zod_1.z.object({ x: finiteNumber, y: finiteNumber }).nullable(), alignmentDeltas: edges.extend({ centerX: finiteNumber, centerY: finiteNumber }).nullable() })),
|
|
108
|
+
warnings: zod_1.z.array(zod_1.z.string()), previewUrl: zod_1.z.string().url(), manifestUrl: zod_1.z.string().url() });
|
|
109
|
+
exports.mediaAnalysisResultSchema = zod_1.z.discriminatedUnion('operation', [exports.framesResultSchema, exports.scenesResultSchema, exports.imageTextResultSchema, exports.videoTextResultSchema, exports.audioTranscriptResultSchema, exports.audioLevelsResultSchema, exports.sampleColorsResultSchema, exports.measureLayoutResultSchema]);
|
package/dist/media.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseClient } from './base';
|
|
2
|
-
import type { TranscribeAudioParams, MeasureAudioLevelsParams, ExtractFramesParams, DetectScenesParams, ReadImageTextParams, ReadVideoTextParams, MediaAnalysisJob } from './media-analysis';
|
|
2
|
+
import type { SampleColorsParams, MeasureLayoutParams, TranscribeAudioParams, MeasureAudioLevelsParams, ExtractFramesParams, DetectScenesParams, ReadImageTextParams, ReadVideoTextParams, MediaAnalysisJob } from './media-analysis';
|
|
3
3
|
import type { ListProfilePostsParams, ListProfilePostsResult, DownloadSocialPostParams, DownloadSocialPostResult } from './social-acquisition';
|
|
4
4
|
import type { ApiResponse } from './types';
|
|
5
5
|
export interface UserMedia {
|
|
@@ -201,6 +201,8 @@ export interface OwnedUploadResponse {
|
|
|
201
201
|
*/
|
|
202
202
|
export declare class MediaClient extends BaseClient {
|
|
203
203
|
/** Transcribe locally with explicit estimated segment/word timing. */
|
|
204
|
+
sampleColors(params: SampleColorsParams): Promise<ApiResponse<MediaAnalysisJob>>;
|
|
205
|
+
measureLayout(params: MeasureLayoutParams): Promise<ApiResponse<MediaAnalysisJob>>;
|
|
204
206
|
transcribeAudio(params: TranscribeAudioParams): Promise<ApiResponse<MediaAnalysisJob>>;
|
|
205
207
|
/** Measure native-channel loudness, RMS/peaks, silence and potential clipping. */
|
|
206
208
|
measureAudioLevels(params: MeasureAudioLevelsParams): Promise<ApiResponse<MediaAnalysisJob>>;
|
package/dist/media.js
CHANGED
|
@@ -7,6 +7,12 @@ const base_1 = require("./base");
|
|
|
7
7
|
*/
|
|
8
8
|
class MediaClient extends base_1.BaseClient {
|
|
9
9
|
/** Transcribe locally with explicit estimated segment/word timing. */
|
|
10
|
+
async sampleColors(params) {
|
|
11
|
+
return this.waitForAnalysis(await this.post('/media/analysis/sample-colors', params));
|
|
12
|
+
}
|
|
13
|
+
async measureLayout(params) {
|
|
14
|
+
return this.waitForAnalysis(await this.post('/media/analysis/measure-layout', params));
|
|
15
|
+
}
|
|
10
16
|
async transcribeAudio(params) {
|
|
11
17
|
return this.waitForAnalysis(await this.post('/media/analysis/transcribe-audio', params));
|
|
12
18
|
}
|
package/dist/tools/media.js
CHANGED
|
@@ -4,6 +4,8 @@ exports.mediaTools = void 0;
|
|
|
4
4
|
const media_analysis_1 = require("../media-analysis");
|
|
5
5
|
const zod_1 = require("zod");
|
|
6
6
|
exports.mediaTools = [
|
|
7
|
+
{ name: 'sample_colors', description: 'Sample observed sRGB colors from an image URL: optional integer point, half-open source-pixel box, or full-size row-major binary RLE mask. Counts alternate background/foreground starting with background (not COCO order). Default whole image, maxColors 8 (1–32). Returns RGBA point and alpha-weighted palette, method, omitted proportion, source hash and preview. Does not recover original authoring colors. Use get_media_analysis if pending.', schema: media_analysis_1.sampleColorsSchema, execute: async (client, params) => client.media.sampleColors(params) },
|
|
8
|
+
{ name: 'measure_layout', description: 'Measure supplied element boxes or binary masks against an image URL. Returns margins, centers, spacing, alignment deltas and overlap. Coordinates are display-oriented source pixels. Masks match source dimensions, row-major counts alternate background/foreground starting with background (not COCO). Up to 32 uniquely identified elements. Visible area/intersection requires masks; boxes do not imply visible ink. Does not detect elements. Use get_media_analysis if pending.', schema: media_analysis_1.measureLayoutSchema, execute: async (client, params) => client.media.measureLayout(params) },
|
|
7
9
|
{ name: 'transcribe_audio', description: 'Transcribe audio/video using an owned local speech model. Returns text, source-relative milliseconds, estimated segment/word timings, model details and an audio preview. No forced alignment or speaker separation. Optional range <=120 seconds and channel 0/1; default averages channels. If pending, use get_media_analysis.', schema: media_analysis_1.transcribeAudioSchema, execute: async (client, params) => client.media.transcribeAudio(params) },
|
|
8
10
|
{ name: 'measure_audio_levels', description: 'Measure audio/video native-channel RMS and sample peaks, integrated/momentary/short-term loudness, estimated true peaks, window-based silence and possible clipping. Distinguishes missing audio from silence and sample peaks from intersample overshoot. Optional range <=120 seconds; default windows 100ms. If pending, use get_media_analysis.', schema: media_analysis_1.measureAudioLevelsSchema, execute: async (client, params) => client.media.measureAudioLevels(params) },
|
|
9
11
|
{ name: 'read_image_text', description: 'Read English image text with raw recognition, polygons in display-oriented source pixels, inferred lines/order and confidence. Includes annotated preview. Empty output does not prove no text. If pending, use get_media_analysis.', schema: media_analysis_1.readImageTextSchema, execute: async (client, params) => client.media.readImageText(params) },
|
package/dist/types.d.ts
CHANGED
|
@@ -20,4 +20,4 @@ export interface ErrorResponse {
|
|
|
20
20
|
export type ApiResponse<T> = SuccessResponse<T> | ErrorResponse;
|
|
21
21
|
export type { PublicPostFailureCode, PublicPostRecovery, PublicPostNextAction, PublicPostFailure } from './post-failure';
|
|
22
22
|
export type { ListProfilePostsParams, ListProfilePostsResult, DownloadSocialPostParams, DownloadSocialPostResult, SocialReferencePost, SocialReferenceAsset } from './social-acquisition';
|
|
23
|
-
export type { TranscribeAudioParams, MeasureAudioLevelsParams, AudioTranscriptResult, AudioLevelsResult, ReadImageTextParams, ReadVideoTextParams, ImageTextResult, VideoTextResult, ExtractFramesParams, DetectScenesParams, FramesResult, ScenesResult, MediaAnalysisResult, MediaAnalysisJob } from "./media-analysis";
|
|
23
|
+
export type { SampleColorsParams, MeasureLayoutParams, SampleColorsResult, MeasureLayoutResult, TranscribeAudioParams, MeasureAudioLevelsParams, AudioTranscriptResult, AudioLevelsResult, ReadImageTextParams, ReadVideoTextParams, ImageTextResult, VideoTextResult, ExtractFramesParams, DetectScenesParams, FramesResult, ScenesResult, MediaAnalysisResult, MediaAnalysisJob } from "./media-analysis";
|