Class: Blueticks::Resources::SunoResource

Inherits:
BaseResource show all
Defined in:
lib/blueticks/resources/suno.rb

Instance Attribute Summary

Attributes inherited from BaseResource

#client

Instance Method Summary collapse

Methods inherited from BaseResource

#initialize

Constructor Details

This class inherits a constructor from Blueticks::BaseResource

Instance Method Details

#accountObject

Get the Suno credit / plan usage for the workspace.



10
11
12
13
# File 'lib/blueticks/resources/suno.rb', line 10

def 
  env = client.request("GET", "/v1/suno/account")
  Types::SunoAccount.from_hash(env && env["data"])
end

#create_song(lyrics:, style:, negative_style: nil, vocal_gender: nil, weirdness: nil, style_influence: nil, audio_influence: nil, instrumental: nil, model: nil, title: nil, upload_id: nil, captcha_token: nil) ⇒ Object

Submit a song generation job. Requires lyrics and style; the many optional knobs mirror the Suno request (vocal_gender, weirdness, style_influence, audio_influence, instrumental, model, title, upload_id, captcha_token, negative_style).



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/blueticks/resources/suno.rb', line 19

def create_song(lyrics:, style:, negative_style: nil, vocal_gender: nil,
                weirdness: nil, style_influence: nil, audio_influence: nil,
                instrumental: nil, model: nil, title: nil, upload_id: nil,
                captcha_token: nil)
  body = { "lyrics" => lyrics, "style" => style }
  body["negativeStyle"] = negative_style unless negative_style.nil?
  body["vocalGender"] = vocal_gender unless vocal_gender.nil?
  body["weirdness"] = weirdness unless weirdness.nil?
  body["styleInfluence"] = style_influence unless style_influence.nil?
  body["audioInfluence"] = audio_influence unless audio_influence.nil?
  body["instrumental"] = instrumental unless instrumental.nil?
  body["model"] = model unless model.nil?
  body["title"] = title unless title.nil?
  body["uploadId"] = upload_id unless upload_id.nil?
  body["captchaToken"] = captcha_token unless captcha_token.nil?
  env = client.request("POST", "/v1/suno/songs", body: body)
  Types::GenerateSongResult.from_hash(env && env["data"])
end

#create_upload(audio_url: nil, audio_base64: nil, file_name: nil) ⇒ Object

Register a reference-audio upload (by URL or base64) for use as an influence on a subsequent song generation.



46
47
48
49
50
51
52
53
# File 'lib/blueticks/resources/suno.rb', line 46

def create_upload(audio_url: nil, audio_base64: nil, file_name: nil)
  body = {}
  body["audioUrl"] = audio_url unless audio_url.nil?
  body["audioBase64"] = audio_base64 unless audio_base64.nil?
  body["fileName"] = file_name unless file_name.nil?
  env = client.request("POST", "/v1/suno/uploads", body: body)
  Types::CreateUploadResult.from_hash(env && env["data"])
end

#get_song(song_id) ⇒ Object

Get a generated song (clip) by id.



39
40
41
42
# File 'lib/blueticks/resources/suno.rb', line 39

def get_song(song_id)
  env = client.request("GET", "/v1/suno/songs/#{song_id}")
  Types::SongClip.from_hash(env && env["data"])
end