TSTextGeneralRintoneVM.swift 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. //
  2. // TSTextGeneralRintoneVM.swift
  3. // AIRingtone
  4. //
  5. // Created by 100Years on 2025/3/6.
  6. //
  7. import ObjectMapper
  8. let kRandomTextToRintone:[String] = [
  9. "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.",
  10. "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.",
  11. "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.",
  12. "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.",
  13. "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.",
  14. "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.",
  15. "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.",
  16. "Generate a Folk ringtone with a fingerpicked acoustic guitar melody and light percussion. Use a BPM of 80-90 for a warm, earthy feel.",
  17. "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.",
  18. "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.",
  19. ]
  20. class TSTextGeneralRintoneVM {
  21. //选择 prompt 类型组
  22. lazy var ptpStyleModels: [TSPTPStyleModel] = {
  23. var ptpStyleModels = [TSPTPStyleModel]()
  24. if let dataArray = Mapper<TSPTPStyleModel>().mapArray(JSONfile: "text_rintone_style.json"){
  25. ptpStyleModels = dataArray
  26. if let model = dataArray.first {
  27. selectPromptModel = model //加上默认的选择
  28. }
  29. }
  30. return ptpStyleModels
  31. }()
  32. //输入框内容
  33. var promptText:String = "" {
  34. didSet{
  35. isCanGennerateBlock?(isCanGennerate)
  36. }
  37. }
  38. //选择的生成图片的 type
  39. var gennerateType:TSGennerateType = .poster{
  40. didSet{
  41. isCanGennerateBlock?(isCanGennerate)
  42. }
  43. }
  44. //选择的 prompt 类型
  45. var selectPromptModel:TSPTPStyleModel?{
  46. didSet{
  47. isCanGennerateBlock?(isCanGennerate)
  48. }
  49. }
  50. //可生成状态变化 block
  51. var isCanGennerateBlock:((Bool)->Void)?
  52. }
  53. extension TSTextGeneralRintoneVM {
  54. //是否满足生成条件
  55. var isCanGennerate:Bool {
  56. if selectPromptModel != nil ,
  57. promptText.replacingOccurrences(of: " ", with: "").count > 0
  58. {
  59. return true
  60. }
  61. return false
  62. }
  63. var prompt:String{
  64. var prompt = promptText
  65. if let selectPromptModel = selectPromptModel {
  66. prompt+=", \(selectPromptModel.prompt)"
  67. }
  68. return prompt
  69. }
  70. var promptSort:String{
  71. return promptText
  72. }
  73. }