12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- //
- // TSTTPInputVM.swift
- // AIEmoji
- //
- // Created by 100Years on 2025/3/11.
- //
- import ObjectMapper
- let kRandomTextToRintone:[String] = [
- "Create a upbeat Pop ringtone with a catchy melody, bright synths, and a cheerful vibe. Use a BPM of 120-130 and keep it energetic and memorable.",
- "Generate a cinematic ringtone with orchestral strings, powerful brass, and a dramatic build-up. Use a BPM of 60-80 for a grand, inspiring feel.",
- "Produce a Lo-Fi ringtone with a relaxed piano melody, soft beats, and warm vinyl crackle. Use a BPM of 70-90 for a cozy, laid-back vibe.",
- "Create a EDM ringtone with a pulsating bassline, uplifting synths, and a quick build-up. Use a BPM of 128-132 for a high-energy, festival-ready sound.",
- "Generate a Jazz ringtone with a smooth saxophone melody, soft piano chords, and a gentle swing rhythm. Use a BPM of 90-100 for a classy, sophisticated tone.",
- "Produce a Funk ringtone with a groovy bassline, rhythmic guitar chops, and punchy brass hits. Use a BPM of 100-110 for a lively, danceable vibe.",
- "Create a Dubstep ringtone with heavy bass wobbles, aggressive synths, and a quick drop. Use a BPM of 140-150 for an intense, edgy sound.",
- "Generate a Folk ringtone with a fingerpicked acoustic guitar melody and light percussion. Use a BPM of 80-90 for a warm, earthy feel.",
- "Produce a Synthwave ringtone with retro arpeggiated synths, a driving beat, and an 80s-inspired vibe. Use a BPM of 100-110 for a nostalgic, futuristic tone.",
- "Create a Techno ringtone with a repetitive bassline, crisp hi-hats, and subtle synth textures. Use a BPM of 125-130 for a sleek, modern sound.",
- ]
- class TSTTPInputVM {
- var selectedStyleIndex:Int = 0
- //选择 prompt 类型组
- lazy var ptpStyleModels: [TSGenerateStyleModel] = {
- var ptpStyleModels = [TSGenerateStyleModel]()
- if let dataArray = Mapper<TSGenerateStyleModel>().mapArray(JSONfile: "text_to_photo_style.json"){
- ptpStyleModels = dataArray
-
- if let model = dataArray.safeObj(At: selectedStyleIndex) {
- selectPromptModel = model //加上默认的选择
- }
- }
-
- return ptpStyleModels
- }()
-
- //输入框内容
- var promptText:String = "" {
- didSet{
- isCanGennerateBlock?(isCanGennerate)
- }
- }
-
- //选择的 prompt 类型
- var selectPromptModel:TSGenerateStyleModel?{
- didSet{
- isCanGennerateBlock?(isCanGennerate)
- }
- }
-
- //可生成状态变化 block
- var isCanGennerateBlock:((Bool)->Void)?
- }
- extension TSTTPInputVM {
- //是否满足生成条件
- var isCanGennerate:Bool {
- if selectPromptModel != nil ,
- promptText.replacingOccurrences(of: " ", with: "").count > 0
- {
- return true
- }
- return false
- }
- var prompt:String{
- var prompt = promptText
- if let selectPromptModel = selectPromptModel,selectPromptModel.prompt.count > 0 {
- prompt = "\(selectPromptModel.prompt)," + prompt
- }
- return prompt
- }
- func saveModel(model:TSActionInfoModel){
- TSRMShared.ttpDBHistory.updateData(model)
- }
- }
|