File size: 3,309 Bytes
17c377a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
import { z } from "zod";

// SRT Segment representing a single subtitle entry
export const srtSegmentSchema = z.object({
  id: z.number(),
  startTime: z.string(), // Format: "00:00:00,000"
  endTime: z.string(),   // Format: "00:00:00,000"
  text: z.string(),
  originalText: z.string().optional(),
});

export type SrtSegment = z.infer<typeof srtSegmentSchema>;

// Anomaly types
export const anomalyTypeSchema = z.enum([
  "unusual_sentence",
  "out_of_context",
  "similar_sounding",
  "grammar_issue",
]);

export type AnomalyType = z.infer<typeof anomalyTypeSchema>;

// Detected anomaly in SRT
export const anomalySchema = z.object({
  id: z.string(),
  segmentId: z.number(),
  type: anomalyTypeSchema,
  flaggedText: z.string(),
  suggestion: z.string(),
  confidence: z.number().min(0).max(1),
  context: z.string().optional(),
  resolved: z.boolean().default(false),
  userCorrection: z.string().optional(),
});

export type Anomaly = z.infer<typeof anomalySchema>;

// Transcription job status
export const jobStatusSchema = z.enum([
  "pending",
  "uploading",
  "processing",
  "transcribing",
  "analyzing",
  "completed",
  "failed",
]);

export type JobStatus = z.infer<typeof jobStatusSchema>;

// Main transcription job
export const transcriptionJobSchema = z.object({
  id: z.string(),
  fileName: z.string(),
  fileSize: z.number(),
  fileType: z.enum(["mp3", "mp4", "audio/mpeg", "audio/mp3", "video/mp4"]),
  status: jobStatusSchema,
  progress: z.number().min(0).max(100),
  userContext: z.string().max(500).optional(),
  segments: z.array(srtSegmentSchema).optional(),
  anomalies: z.array(anomalySchema).optional(),
  mediaUrl: z.string().optional(),
  createdAt: z.string(),
  completedAt: z.string().optional(),
  errorMessage: z.string().optional(),
});

export type TranscriptionJob = z.infer<typeof transcriptionJobSchema>;

// Upload request
export const uploadRequestSchema = z.object({
  userContext: z.string().max(500).optional(),
});

export type UploadRequest = z.infer<typeof uploadRequestSchema>;

// Correction request
export const correctionRequestSchema = z.object({
  jobId: z.string(),
  anomalyId: z.string(),
  correction: z.string(),
  applyToSimilar: z.boolean().default(false),
});

export type CorrectionRequest = z.infer<typeof correctionRequestSchema>;

// Batch correction request
export const batchCorrectionRequestSchema = z.object({
  jobId: z.string(),
  corrections: z.array(z.object({
    anomalyId: z.string(),
    correction: z.string(),
  })),
});

export type BatchCorrectionRequest = z.infer<typeof batchCorrectionRequestSchema>;

// API response types
export const apiResponseSchema = z.object({
  success: z.boolean(),
  message: z.string().optional(),
  data: z.any().optional(),
});

export type ApiResponse<T = unknown> = {
  success: boolean;
  message?: string;
  data?: T;
};

// Similar anomalies for batch correction
export const similarAnomaliesSchema = z.object({
  original: anomalySchema,
  similar: z.array(anomalySchema),
});

export type SimilarAnomalies = z.infer<typeof similarAnomaliesSchema>;

// Update segment request
export const updateSegmentRequestSchema = z.object({
  jobId: z.string(),
  segmentId: z.number(),
  text: z.string(),
});

export type UpdateSegmentRequest = z.infer<typeof updateSegmentRequestSchema>;