jbilcke-hf HF staff commited on
Commit
8c7d08c
1 Parent(s): eae869c
src/app/api/v1/edit/dialogues/processShot.ts CHANGED
@@ -4,6 +4,7 @@ import { getSpeechBackgroundAudioPrompt } from "@aitube/engine"
4
 
5
  import { startOfSegment1IsWithinSegment2 } from "@/lib/utils/startOfSegment1IsWithinSegment2"
6
  import { generateSpeechWithParlerTTS } from "@/app/api/generators/speech/generateVoiceWithParlerTTS"
 
7
 
8
  export async function processShot({
9
  shotSegment,
@@ -37,6 +38,17 @@ export async function processShot({
37
  })
38
  shotDialogueSegment.assetSourceType = getClapAssetSourceType(shotDialogueSegment.assetUrl)
39
 
 
 
 
 
 
 
 
 
 
 
 
40
  } catch (err) {
41
  console.log(`[api/generate/dialogues] processShot: failed to generate audio: ${err}`)
42
  throw err
 
4
 
5
  import { startOfSegment1IsWithinSegment2 } from "@/lib/utils/startOfSegment1IsWithinSegment2"
6
  import { generateSpeechWithParlerTTS } from "@/app/api/generators/speech/generateVoiceWithParlerTTS"
7
+ import { getMediaInfo } from "@/app/api/utils/getMediaInfo"
8
 
9
  export async function processShot({
10
  shotSegment,
 
38
  })
39
  shotDialogueSegment.assetSourceType = getClapAssetSourceType(shotDialogueSegment.assetUrl)
40
 
41
+ const { durationInMs, durationInSec, hasAudio } = await getMediaInfo(shotDialogueSegment.assetUrl)
42
+
43
+ shotDialogueSegment.assetDurationInMs = durationInMs
44
+ shotSegment.assetDurationInMs = durationInMs
45
+
46
+ // we update the duration of all the segments for this shot
47
+ // (it is possible that this makes the two previous lines redundant)
48
+ clap.segments.filter(s => {
49
+ s.assetDurationInMs = durationInMs
50
+ })
51
+
52
  } catch (err) {
53
  console.log(`[api/generate/dialogues] processShot: failed to generate audio: ${err}`)
54
  throw err