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