ugcinc 4.22.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.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mediaAnalysisResultSchema = 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);
@@ -62,4 +62,48 @@ exports.videoTextResultSchema = zod_1.z.object({ version: zod_1.z.literal(1), op
62
62
  coverage: zod_1.z.object({ mode: zod_1.z.enum(['fast', 'frame_scan']), range: intervalSchema, complete: zod_1.z.boolean(), uninspected: zod_1.z.array(intervalSchema),
63
63
  inspected: zod_1.z.array(intervalSchema.extend({ frameIndex: zod_1.z.number().int(), sourcePts: zod_1.z.string() })) }),
64
64
  });
65
- exports.mediaAnalysisResultSchema = zod_1.z.discriminatedUnion('operation', [exports.framesResultSchema, exports.scenesResultSchema, exports.imageTextResultSchema, exports.videoTextResultSchema]);
65
+ const audioRange = zod_1.z.object({ startMs: time, endMs: time }).strict().refine(v => v.endMs > v.startMs && v.endMs - v.startMs <= 120000, 'Audio range must be positive and at most 120 seconds');
66
+ exports.transcribeAudioSchema = zod_1.z.object({ url: videoUrl, range: audioRange.optional(),
67
+ language: zod_1.z.enum(['auto', 'en', 'es', 'fr', 'de', 'it', 'pt', 'ja', 'ko', 'zh', 'ar', 'hi', 'ru']).default('auto'),
68
+ timing: zod_1.z.enum(['word', 'segment']).default('word'), channel: zod_1.z.number().int().min(0).max(1).optional() }).strict();
69
+ exports.measureAudioLevelsSchema = zod_1.z.object({ url: videoUrl, range: audioRange.optional(),
70
+ windowMs: zod_1.z.number().finite().min(20).max(5000).default(100), silenceThresholdDbfs: zod_1.z.number().finite().min(-100).max(-10).default(-50) }).strict();
71
+ const audioSourceSchema = zod_1.z.object({ sha256: zod_1.z.string(), bytes: zod_1.z.number(), hasAudio: zod_1.z.boolean(), durationMs: time, originStartMs: zod_1.z.number(),
72
+ audioStartPts: zod_1.z.string().nullable(), audioTimeBase: zod_1.z.string().nullable(), sampleRate: zod_1.z.number().nullable(), channels: zod_1.z.number().nullable(), channelLayout: zod_1.z.string().nullable(), audioOffsetMs: zod_1.z.number().nullable() });
73
+ const audioCoverageSchema = zod_1.z.object({ requestedRange: intervalSchema, analyzed: zod_1.z.array(intervalSchema), withoutAudio: zod_1.z.array(intervalSchema), sampleRoundingToleranceMs: time });
74
+ const dbValue = zod_1.z.number().finite().nullable();
75
+ const levelChannelSchema = zod_1.z.object({ index: zod_1.z.number().int(), rmsDbfs: dbValue, samplePeakDbfs: dbValue, potentialClippedSamples: zod_1.z.number().int().nonnegative() });
76
+ exports.audioLevelsResultSchema = zod_1.z.object({ version: zod_1.z.literal(1), operation: zod_1.z.literal('measure_audio_levels'), source: audioSourceSchema,
77
+ status: zod_1.z.enum(['no_audio', 'measured']), coverage: audioCoverageSchema,
78
+ channels: zod_1.z.array(levelChannelSchema.extend({ truePeakDbtp: dbValue, sampleCount: zod_1.z.number().int(), intersampleOvershoot: zod_1.z.boolean() })),
79
+ windows: zod_1.z.array(intervalSchema.extend({ channels: zod_1.z.array(levelChannelSchema) })), silence: zod_1.z.array(intervalSchema), integratedLufs: dbValue, truePeakDbtp: dbValue,
80
+ loudnessTimeline: zod_1.z.array(intervalSchema.extend({ momentaryLufs: dbValue, shortTermLufs: dbValue })),
81
+ settings: zod_1.z.object({ windowMs: zod_1.z.number(), silenceThresholdDbfs: zod_1.z.number(), silenceMethod: zod_1.z.literal('all-channel-window-rms'), potentialClippingThreshold: zod_1.z.number(), channelPolicy: zod_1.z.literal('native-separate'), loudnessMethod: zod_1.z.literal('FFmpeg-ebur128-native-channels'), ffmpegVersion: zod_1.z.string() }),
82
+ warnings: zod_1.z.array(zod_1.z.string()), previewUrl: zod_1.z.string().url().optional(), manifestUrl: zod_1.z.string().url() });
83
+ const speechModelSchema = zod_1.z.object({ name: zod_1.z.string(), repository: zod_1.z.string(), revision: zod_1.z.string(), sha256: zod_1.z.record(zod_1.z.string()), runtime: zod_1.z.string(), device: zod_1.z.literal('cpu'), computeType: zod_1.z.literal('int8'), vad: zod_1.z.string(), beamSize: zod_1.z.number(), temperature: zod_1.z.number(), conditionOnPreviousText: zod_1.z.boolean() });
84
+ const estimatedWord = zod_1.z.object({ text: zod_1.z.string(), startMs: zod_1.z.number().finite(), endMs: zod_1.z.number().finite(), timing: zod_1.z.literal('estimated'), probability: zod_1.z.number() });
85
+ exports.audioTranscriptResultSchema = zod_1.z.object({ version: zod_1.z.literal(1), operation: zod_1.z.literal('transcribe_audio'), source: audioSourceSchema,
86
+ status: zod_1.z.enum(['no_audio', 'no_speech_detected', 'transcribed']), text: zod_1.z.string(), coverage: audioCoverageSchema, model: speechModelSchema,
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
+ 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
+ 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
+ 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 { 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 {
@@ -200,6 +200,12 @@ export interface OwnedUploadResponse {
200
200
  * Client for managing media files
201
201
  */
202
202
  export declare class MediaClient extends BaseClient {
203
+ /** Transcribe locally with explicit estimated segment/word timing. */
204
+ sampleColors(params: SampleColorsParams): Promise<ApiResponse<MediaAnalysisJob>>;
205
+ measureLayout(params: MeasureLayoutParams): Promise<ApiResponse<MediaAnalysisJob>>;
206
+ transcribeAudio(params: TranscribeAudioParams): Promise<ApiResponse<MediaAnalysisJob>>;
207
+ /** Measure native-channel loudness, RMS/peaks, silence and potential clipping. */
208
+ measureAudioLevels(params: MeasureAudioLevelsParams): Promise<ApiResponse<MediaAnalysisJob>>;
203
209
  /** Read English text with source-coordinate polygons and an annotated preview. */
204
210
  readImageText(params: ReadImageTextParams): Promise<ApiResponse<MediaAnalysisJob>>;
205
211
  readVideoText(params: ReadVideoTextParams): Promise<ApiResponse<MediaAnalysisJob>>;
package/dist/media.js CHANGED
@@ -6,6 +6,20 @@ const base_1 = require("./base");
6
6
  * Client for managing media files
7
7
  */
8
8
  class MediaClient extends base_1.BaseClient {
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
+ }
16
+ async transcribeAudio(params) {
17
+ return this.waitForAnalysis(await this.post('/media/analysis/transcribe-audio', params));
18
+ }
19
+ /** Measure native-channel loudness, RMS/peaks, silence and potential clipping. */
20
+ async measureAudioLevels(params) {
21
+ return this.waitForAnalysis(await this.post('/media/analysis/measure-audio-levels', params));
22
+ }
9
23
  /** Read English text with source-coordinate polygons and an annotated preview. */
10
24
  async readImageText(params) {
11
25
  return this.waitForAnalysis(await this.post('/media/analysis/read-image-text', params));
@@ -4,6 +4,10 @@ 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) },
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) },
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) },
7
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) },
8
12
  { name: 'read_video_text', description: 'Read English video text and positional changes. fast samples frames (default 1000ms); frame_scan inspects every decoded frame in range. Returns source PTS, observed text tracks and explicit uninspected gaps. At most 240 inspected frames and 120 seconds per request. Sampling cannot guarantee exact appearance/disappearance. If pending, use get_media_analysis.', schema: media_analysis_1.readVideoTextSchema, execute: async (client, params) => client.media.readVideoText(params) },
9
13
  { name: 'extract_frames', description: 'Extract video frames at timestampsMs or a range {startMs,endMs,intervalMs}; milliseconds relative to the first displayed frame. Returns actual decoded times and optional contact sheet. At most 48 samples. If pending, use get_media_analysis with jobId.', schema: media_analysis_1.extractFramesSchema, execute: async (client, params) => client.media.extractFrames(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 { 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";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ugcinc",
3
- "version": "4.22.0",
3
+ "version": "4.24.0",
4
4
  "description": "TypeScript/JavaScript client for the UGC Inc API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",