1

I wrote a program for practicing note identification on a guitar:

note1 = {"A.", "B", "C", "D", "E", "F", "G"};
note2 = {" Sharp", " Natural", " Flat"};
string = {"first  ", "second  ", "third  ", "fourth ", "fifth ", 
   "sixth "};

list = StringJoin[#] & /@ Tuples[{note1, note2}]; list2 = Flatten[ Table[RandomSample[StringJoin[#] & /@ Tuples[{string, list}]], {i, 1, 1}]]; For[i = 1, i <= Length[list2], i++, Speak[list2[[i]]]; Pause[2.5]; ]

I do not have a Mathematica license, so I want to use Wolfram Cloud. The problem is that the server times out before the for-loop gets through the entire list. Is there anyway to send the speak command to the server, then have it send back the entire list in audio format?

ngc1300
  • 171
  • 1
  • 7

1 Answers1

3

This works for me on Wolfram Cloud:

note1 = {"A.", "B", "C", "D", "E", "F", "G"};
note2 = {" Sharp", " Natural", " Flat"};
string = {"first  ", "second  ", "third  ", "fourth ", "fifth ", 
   "sixth "};

list = StringJoin[#] & /@ Tuples[{note1, note2}]; list2 = Flatten[ Table[RandomSample[StringJoin[#] & /@ Tuples[{string, list}]], {i, 1, 1}]]; pauseTime = 2;(in seconds) audio = AudioJoin[ AudioPad[#, pauseTime] & /@ SpeechSynthesize /@ list2]

To speed the spoken part up, add AudioTimeStretch with an appropriate factor. I had to rewrite the code a bit, as Wolfram Cloud doesn't seem to like too many nested Map-functions. Adjust audioSpeed to taste:

Clear[note1,note2,string,list,list2,pauseTime,audio,audioSpeed];
note1 = {"A.", "B", "C", "D", "E", "F", "G"};
note2 = {" Sharp", " Natural", " Flat"};
string = {"first  ", "second  ", "third  ", "fourth ", "fifth ", 
   "sixth "};
   list = StringJoin[#] & /@ Tuples[{note1, note2}];
list2 = Flatten[
   Table[RandomSample[StringJoin[#] & /@ Tuples[{string, list}]], {i, 
     1, 1}]];
pauseTime = 2;(*in seconds*)
audioSpeed=0.9;(*Values < 1 for speeding up*)
   speedaudio=AudioJoin[Riffle[AudioTimeStretch[SpeechSynthesize[#],audioSpeed,Method->"Speech"]&/@list2,AudioGenerator["Silence",pauseTime]]]
rowsi
  • 395
  • 1
  • 10