@audiofool/moondog 0.3.1 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -130,7 +130,7 @@ const slashCommands = [
130
130
  { name: "web", description: N_("Look things up on public music sites") },
131
131
  { name: "service", description: N_("Choose where Moondog plays music") },
132
132
  { name: "library", description: N_("Your saved songs and playlists") },
133
- { name: "generation", description: N_("Let Moondog make music on this Mac") },
133
+ { name: "generation", description: process.platform === "darwin" ? N_("Let Moondog make music on this Mac") : N_("Let Moondog make music on this computer") },
134
134
  { name: "onair", description: N_("Go on air: Moondog keeps making music from your taste") },
135
135
  { name: "spotify", description: N_("Connect and control Spotify") },
136
136
  { name: "skip", description: N_("Skip to the next song preview or stream track") },
@@ -791,20 +791,25 @@ export async function runMoondogTui({
791
791
  }
792
792
  // Music making can be turned off, here or in the window, after the room opened.
793
793
  if (!application.streamReady?.()) {
794
- setFooter(tr("Turn on music making first: /generation on."), warning);
794
+ setFooter(tr("Turn on Stable Audio 3 first: /generation on."), warning);
795
795
  return null;
796
796
  }
797
797
  return translator(application.locale)("onAir.request");
798
798
  };
799
799
 
800
- // Making music on this Mac. /generation says where it stands; /generation on [folder] turns it on,
801
- // with the folder of Stability AI's MLX build when it is not the usual one; /generation off turns it off.
800
+ // Making music on this computer. /generation says where it stands; /generation on [folder] turns it on,
801
+ // with the folder of Stability AI's build when it is not the usual one; /generation off turns it off.
802
+ // Off the Mac, the build is the CPU one, and the texts say "this computer" instead of "this Mac".
802
803
  // Where the core can set Stable Audio 3 up itself (generation.setup), /generation download, use, remove
803
804
  // and cancel manage the models Moondog keeps in its own folder. The window runs the same job, so a
804
805
  // download started there shows here too.
805
806
  const home = homedir();
806
807
  const shownFolder = (folder) => sanitizeTerminalText(String(folder ?? "")).replace(home, "~");
807
808
  const setup = typeof generation?.setup?.install === "function" ? generation.setup : null;
809
+ // A generator that doesn't name its platform is the Mac's, the only one before the CPU build.
810
+ const onMac = () => (generation?.status?.()?.platform ?? "darwin") === "darwin";
811
+ const unsupportedText = () => onMac() ? tr("Stable Audio 3 needs a Mac with Apple silicon, so it doesn't run here. Moondog writes its tracks as scores instead.")
812
+ : tr("Stable Audio 3 doesn't run on this computer: it needs Windows or Linux on x64, Linux on ARM, or a Mac with Apple silicon. Moondog writes its tracks as scores instead.");
808
813
  // The two models offered, by the word the listener types; sizes are the weights in all, before the
809
814
  // setup reports its own.
810
815
  const sa3Models = {
@@ -836,7 +841,10 @@ export async function runMoondogTui({
836
841
  // One short sentence for a download that stopped on an error, by the setup's code, with the way to try again.
837
842
  const setupErrorText = (error) => {
838
843
  const code = typeof error === "string" ? error : error?.code;
839
- if (code === "setup_disk_full") return tr("There isn't enough free space on this Mac for the download. Free some up, then use /generation download again.");
844
+ if (code === "setup_disk_full") {
845
+ return onMac() ? tr("There isn't enough free space on this Mac for the download. Free some up, then use /generation download again.")
846
+ : tr("There isn't enough free space on this computer for the download. Free some up, then use /generation download again.");
847
+ }
840
848
  if (code === "setup_verification_failed") return tr("A downloaded file didn't match the one Stability AI publishes, so Moondog deleted it. Use /generation download to try again.");
841
849
  if (code === "setup_offline" || code === "setup_download_failed") return tr("The download couldn't reach its source. Check your connection, then use /generation download to try again.");
842
850
  if (code === "setup_python_failed") return tr("Stable Audio 3's Python environment couldn't be set up. Check your connection, then use /generation download to try again.");
@@ -907,28 +915,41 @@ export async function runMoondogTui({
907
915
  };
908
916
  const generationMessage = (status) => {
909
917
  const folder = shownFolder(status?.path);
910
- if (status?.install === "unsupported") return tr("Stable Audio 3 needs a Mac with Apple silicon, so Moondog can't make music here.");
911
- if (status?.state === "ready") return tr("Moondog makes music on this Mac with Stable Audio 3, powered by Stability AI. Ask for a track. Stable Audio 3 runs offline, and the track stays on this Mac.");
918
+ const command = status?.platform === "win32" ? ".\\install.bat --download medium" : "./install.sh --download medium";
919
+ if (status?.install === "unsupported") return unsupportedText();
920
+ if (status?.state === "ready") {
921
+ return onMac() ? tr("Moondog makes music on this Mac with Stable Audio 3, powered by Stability AI. Ask for a track. Stable Audio 3 runs offline, and the track stays on this Mac.")
922
+ : tr("Moondog makes music on this computer with Stable Audio 3, powered by Stability AI. Ask for a track. Stable Audio 3 runs offline on the processor, so a track takes a little while, and it stays on this computer.");
923
+ }
912
924
  // Moondog's own install, or nothing anywhere yet: a download sets it up.
913
925
  if (setup && status?.install !== "ready" && (status?.managed || (status?.source === "default" && status?.install === "missing"))) {
914
- if (status?.state === "off") return tr("Making music on this Mac is off. Get Stable Audio 3 with /generation download medium, or small for a lighter model; music making turns on when it's done.");
926
+ if (status?.state === "off") {
927
+ return onMac() ? tr("Stable Audio 3 is off on this Mac. Get it with /generation download medium, or small for a lighter model; it turns on when it's done. Until then, Moondog writes a track as a score when you ask.")
928
+ : tr("Stable Audio 3 is off on this computer. Get it with /generation download medium, or small for a lighter, faster model; it turns on when it's done. Until then, Moondog writes a track as a score when you ask.");
929
+ }
915
930
  const model = status?.model in sa3Models ? status.model : "medium";
916
931
  return tr("Stable Audio 3 {model} isn't downloaded yet. Get it with /generation download {choice}.", { model: modelName(model), choice: sa3Models[model].choice });
917
932
  }
918
933
  if (status?.state === "off") {
919
- if (status.install === "ready" && status.managed) return tr("Making music on this Mac is off. Stable Audio 3 {model} is ready; turn it on with /generation on.", { model: modelName(status.model) });
920
- if (status.install === "ready") return tr("Making music on this Mac is off. Stable Audio 3 is ready at {folder}; turn it on with /generation on.", { folder });
921
- if (status.install === "incomplete") return tr("Making music on this Mac is off, and Stable Audio 3 at {folder} isn't fully installed. Run ./install.sh --download medium there, then use /generation on.", { folder });
922
- return tr("Making music on this Mac is off, and Stable Audio 3 isn't at {folder}. Install Stability AI's MLX build from github.com/Stability-AI/stable-audio-3, then use /generation on with its folder.", { folder });
934
+ if (!onMac()) {
935
+ if (status.install === "ready" && status.managed) return tr("Stable Audio 3 is off on this computer, and {model} is ready; turn it on with /generation on. Until then, Moondog writes a track as a score when you ask.", { model: modelName(status.model) });
936
+ if (status.install === "ready") return tr("Stable Audio 3 is off on this computer, and ready at {folder}; turn it on with /generation on. Until then, Moondog writes a track as a score when you ask.", { folder });
937
+ if (status.install === "incomplete") return tr("Stable Audio 3 is off on this computer, and the one at {folder} isn't fully installed. Run {command} there, then use /generation on. Until then, Moondog writes a track as a score when you ask.", { folder, command });
938
+ return tr("Stable Audio 3 is off on this computer, and it isn't at {folder}. Install Stability AI's CPU build (optimized/tflite) from github.com/Stability-AI/stable-audio-3, then use /generation on with its folder. Until then, Moondog writes a track as a score when you ask.", { folder });
939
+ }
940
+ if (status.install === "ready" && status.managed) return tr("Stable Audio 3 is off on this Mac, and {model} is ready; turn it on with /generation on. Until then, Moondog writes a track as a score when you ask.", { model: modelName(status.model) });
941
+ if (status.install === "ready") return tr("Stable Audio 3 is off on this Mac, and ready at {folder}; turn it on with /generation on. Until then, Moondog writes a track as a score when you ask.", { folder });
942
+ if (status.install === "incomplete") return tr("Stable Audio 3 is off on this Mac, and the one at {folder} isn't fully installed. Run {command} there, then use /generation on. Until then, Moondog writes a track as a score when you ask.", { folder, command });
943
+ return tr("Stable Audio 3 is off on this Mac, and it isn't at {folder}. Install Stability AI's MLX build from github.com/Stability-AI/stable-audio-3, then use /generation on with its folder. Until then, Moondog writes a track as a score when you ask.", { folder });
923
944
  }
924
945
  if (status?.state === "incomplete") {
925
946
  return status.missing === "weights"
926
- ? tr("Stable Audio 3 at {folder} doesn't have the Medium model yet. Run ./install.sh --download medium there, then use /generation again.", { folder })
927
- : tr("Stable Audio 3 at {folder} isn't installed yet. Run ./install.sh --download medium there, then use /generation again.", { folder });
947
+ ? tr("Stable Audio 3 at {folder} doesn't have the Medium model yet. Run {command} there, then use /generation again.", { folder, command })
948
+ : tr("Stable Audio 3 at {folder} isn't installed yet. Run {command} there, then use /generation again.", { folder, command });
928
949
  }
929
950
  return tr("Stable Audio 3 isn't at {folder}. Use /generation on with the folder that holds its sa3 script.", { folder });
930
951
  };
931
- const generationFooter = (status) => setFooter(status.state === "ready" ? tr("Music making on.") : status.state === "off" ? tr("Music making off.") : tr("Music making isn't ready."),
952
+ const generationFooter = (status) => setFooter(status.state === "ready" ? tr("Stable Audio 3 on.") : status.state === "off" ? tr("Stable Audio 3 off.") : tr("Stable Audio 3 isn't ready."),
932
953
  status.state === "ready" || status.state === "off" ? dim : warning);
933
954
  const setupUsage = () => tr("Use /generation download, use or remove with medium or small, or /generation cancel.");
934
955
  // /generation download, use, remove and cancel. A first download asks for the licenses with --agree;
@@ -943,8 +964,8 @@ export async function runMoondogTui({
943
964
  }
944
965
  const status = await readSetup();
945
966
  if (status?.supported === false) {
946
- addMoondogMessage(tr("Stable Audio 3 needs a Mac with Apple silicon, so Moondog can't make music here."));
947
- setFooter(tr("Music making isn't ready."), warning);
967
+ addMoondogMessage(unsupportedText());
968
+ setFooter(tr("Stable Audio 3 isn't ready."), warning);
948
969
  return;
949
970
  }
950
971
  const running = status?.job && !status.job.error ? status.job : null;
@@ -964,7 +985,8 @@ export async function runMoondogTui({
964
985
  return;
965
986
  }
966
987
  if (entry.state === "ready") {
967
- addMoondogMessage(tr("Stable Audio 3 {model} is already on this Mac. Use it with /generation use {choice}.", { model: name, choice }));
988
+ addMoondogMessage(onMac() ? tr("Stable Audio 3 {model} is already on this Mac. Use it with /generation use {choice}.", { model: name, choice })
989
+ : tr("Stable Audio 3 {model} is already on this computer. Use it with /generation use {choice}.", { model: name, choice }));
968
990
  setFooter(tr("Already downloaded."));
969
991
  return;
970
992
  }
@@ -995,7 +1017,7 @@ export async function runMoondogTui({
995
1017
  if (action === "use") {
996
1018
  if (entry.state !== "ready") {
997
1019
  addMoondogMessage(tr("Stable Audio 3 {model} isn't downloaded yet. Get it with /generation download {choice}.", { model: name, choice }));
998
- setFooter(tr("Music making isn't ready."), warning);
1020
+ setFooter(tr("Stable Audio 3 isn't ready."), warning);
999
1021
  return;
1000
1022
  }
1001
1023
  const result = await generation.save({ enabled: true, source: "managed", model });
@@ -1010,23 +1032,30 @@ export async function runMoondogTui({
1010
1032
  return;
1011
1033
  }
1012
1034
  if (entry.state === "absent") {
1013
- setFooter(tr("Stable Audio 3 {model} isn't on this Mac.", { model: name }));
1035
+ setFooter(onMac() ? tr("Stable Audio 3 {model} isn't on this Mac.", { model: name }) : tr("Stable Audio 3 {model} isn't on this computer.", { model: name }));
1014
1036
  return;
1015
1037
  }
1016
1038
  if (!flags.includes("--yes")) {
1017
1039
  const last = Object.keys(sa3Models).every((other) => other === model || (status?.models?.[other]?.state ?? "absent") === "absent");
1018
1040
  const size = gigabytes(entry.bytes || entry.total || sa3Models[model].total);
1019
- addMoondogMessage(last
1020
- ? tr("Removing Stable Audio 3 {model} deletes its {size} GB from this Mac. It's the last model, so the rest of Moondog's Stable Audio 3 setup goes too. To go ahead: /generation remove {choice} --yes", { model: name, size, choice })
1021
- : tr("Removing Stable Audio 3 {model} deletes its {size} GB from this Mac. To go ahead: /generation remove {choice} --yes", { model: name, size, choice }));
1041
+ if (onMac()) {
1042
+ addMoondogMessage(last
1043
+ ? tr("Removing Stable Audio 3 {model} deletes its {size} GB from this Mac. It's the last model, so the rest of Moondog's Stable Audio 3 setup goes too. To go ahead: /generation remove {choice} --yes", { model: name, size, choice })
1044
+ : tr("Removing Stable Audio 3 {model} deletes its {size} GB from this Mac. To go ahead: /generation remove {choice} --yes", { model: name, size, choice }));
1045
+ } else {
1046
+ // The CPU build also keeps a cache beside each model it has run, about the model's own size, which goes too.
1047
+ addMoondogMessage(last
1048
+ ? tr("Removing Stable Audio 3 {model} deletes its {size} GB from this computer, and the cache it made there. It's the last model, so the rest of Moondog's Stable Audio 3 setup goes too. To go ahead: /generation remove {choice} --yes", { model: name, size, choice })
1049
+ : tr("Removing Stable Audio 3 {model} deletes its {size} GB from this computer, and the cache it made there. To go ahead: /generation remove {choice} --yes", { model: name, size, choice }));
1050
+ }
1022
1051
  setFooter(tr("Nothing removed yet."));
1023
1052
  return;
1024
1053
  }
1025
1054
  await setup.remove(model);
1026
1055
  await readSetup().catch(() => null);
1027
1056
  const after = await generation.check().catch(() => null);
1028
- addMoondogMessage(tr("Removed Stable Audio 3 {model} from this Mac.", { model: name }));
1029
- setFooter(after?.state === "ready" ? tr("Removed.") : tr("Removed. Music making isn't ready."), after?.state === "ready" ? success : warning);
1057
+ addMoondogMessage(onMac() ? tr("Removed Stable Audio 3 {model} from this Mac.", { model: name }) : tr("Removed Stable Audio 3 {model} from this computer.", { model: name }));
1058
+ setFooter(after?.state === "ready" ? tr("Removed.") : tr("Removed. Stable Audio 3 isn't ready."), after?.state === "ready" ? success : warning);
1030
1059
  };
1031
1060
  const manageGeneration = async (args) => {
1032
1061
  const [action, ...rest] = args;