@@ -389,21 +389,42 @@ class SunoApi {
389
389
* @returns A promise that resolves to an AudioInfo object representing the generated stems.
390
390
*/
391
391
public async generateStems ( song_id : string ) : Promise < AudioInfo [ ] > {
392
+ await this . keepAlive ( false ) ;
392
393
const response = await this . client . post (
393
394
`${ SunoApi . BASE_URL } /api/edit/stems/${ song_id } ` , { }
394
395
) ;
396
+
395
397
console . log ( 'generateStems response:\n' , response ?. data ) ;
396
398
return response . data . clips . map ( ( clip : any ) => ( {
397
399
id : clip . id ,
398
400
status : clip . status ,
399
- metadata : clip . metadata ,
400
401
created_at : clip . created_at ,
401
402
title : clip . title ,
402
403
stem_from_id : clip . metadata . stem_from_id ,
403
404
duration : clip . metadata . duration
404
405
} ) ) ;
405
406
}
406
407
408
+
409
+ /**
410
+ * Get the lyric alignment for a song.
411
+ * @param song_id The ID of the song to get the lyric alignment for.
412
+ * @returns A promise that resolves to an object containing the lyric alignment.
413
+ */
414
+ public async getLyricAlignment ( song_id : string ) : Promise < object > {
415
+ await this . keepAlive ( false ) ;
416
+ const response = await this . client . get ( `${ SunoApi . BASE_URL } /api/gen/${ song_id } /aligned_lyrics/v2/` ) ;
417
+
418
+ console . log ( `getLyricAlignment ~ response:` , response . data ) ;
419
+ return response . data ?. aligned_words . map ( ( transcribedWord : any ) => ( {
420
+ word : transcribedWord . word ,
421
+ start_s : transcribedWord . start_s ,
422
+ end_s : transcribedWord . end_s ,
423
+ success : transcribedWord . success ,
424
+ p_align : transcribedWord . p_align
425
+ } ) ) ;
426
+ }
427
+
407
428
/**
408
429
* Processes the lyrics (prompt) from the audio metadata into a more readable format.
409
430
* @param prompt The original lyrics text.
0 commit comments