Author Topic: Sci-Fi Techno-Babble Generator  (Read 10649 times)

0 Members and 1 Guest are viewing this topic.

Offline SirCrow

  • Forum Regular
  • Posts: 144
    • View Profile
Sci-Fi Techno-Babble Generator
« on: November 20, 2018, 12:59:21 pm »
I wrote this specifically to be used in my StarBlast game to generate semi-random chatter or dialogue (typical sci-fi technical jargon, as on-screen text) between the pilots of the asteroid-blasting spacecraft.  In the game itself, the communication also involves their leader/commander, as well as their base of operations, Central Command.

Code: QB64: [Select]
  1.  
  2. _FULLSCREEN ': DEFINT A-Z
  3.  
  4.     GOSUB Tech_Talk: COLOR 7, 0
  5.     PRINT Chat$: Cnt = Cnt + 1
  6.     IF Cnt = 22 THEN COLOR 11: PRINT "[Esc] to exit; other key to continue";: SLEEP: Cnt = 0: CLS
  7.     'IF INSTR(Chat$, "seems") THEN SLEEP
  8.     'IF INSTR(Chat$, "mother") THEN SLEEP
  9.     'IF INSTR(Chat$, "burp") THEN SLEEP
  10. LOOP UNTIL INKEY$ = CHR$(27): END '======================================================
  11.  
  12.  
  13. '###########################################################################################################
  14.  
  15. Chat_Opener: 'First letter must be capital (but addition of "Commander, " will LCASE it.)
  16. DATA I believe,"I don't know why, but",I think,It seems,"For some reason,","Oddly,","Okay,"
  17. DATA "I don't get it....",Strange....,This is odd....,This is weird....
  18. DATA XXX
  19.  
  20. Tech_Adj:
  21. DATA adaptive,antimatter,asymmetric,barometric,bilateral,binary,biogenic,central,continuous,dimensional,directional
  22. DATA external,forward,gravitational,hi-res,high-level,hypersensitive,internal,ionic,isolinear,lateral,level-1,logical
  23. DATA long-range,low-gain,low-level,low-magnitude,low-tolerance
  24. DATA multidirectional,multiphasic,multispectral,primary,radial,redundant,repeating,reverse,secondary,spatial,spectral
  25. DATA stage-3,temporal,tri-level,tri-stage,vertical,zero-point
  26. DATA XXX
  27.  
  28. Tech_Noun_1:
  29. DATA alignment,contrast,convergence,echo,frequency,impulse,latitude,particle,pressure,quantum,resistance
  30. DATA resonance,tachyon,wavelength
  31. DATA ABX,ACE,AGT,CR-52,DST-35,LTS-1804,MX-44,PU-36: 'Thanks, Marvin the Martian!
  32. DATA XXX
  33.  
  34. Tech_Noun_2:
  35. DATA analyser,computer,coupler,decoupler,detector,decoupler,stabiliser
  36. DATA XXX
  37.  
  38. Chat_Closer:
  39. DATA has decided to reset itself,has gone all screwy on me,has gone offline,has just shut down,has shut down
  40. DATA is acting funny,is acting up,is malfunctioning,is on the fritz,keeps cutting my engines,recommends recalibration
  41. DATA says I need to reset it,says I need to shut it down,says I should recalibrate it
  42. DATA seems to be faulty,seems to have reset itself,seems to be shutting down
  43. DATA wants to recalibrate,wants to reset itself,wants to shut down
  44. DATA has just insulted my mother,just burped,just farted: 'Far below, "IF RN > C - 3" refers to these 3 items
  45. DATA XXX
  46. '############################################################################################################
  47.  
  48.  
  49. DataCount:
  50. C = 0: DO: READ D$: C = C + 1: LOOP UNTIL D$ = "XXX": D$ = "": C = C - 1
  51.  
  52.  
  53. Tech_Talk: 'Here, we'll assemble a "tech thing" using parts randomly selected from
  54. '           Tech Adjective and Tech Noun (2), with the option of a middle Noun (1).
  55. '           This Tech Thing will be inserted into a line of Pilot dialogue.
  56.  
  57.  
  58. IF RND < .5 THEN Chat$ = "My " ELSE Chat$ = "The " 'Optional possessive pronoun or definite article
  59.  
  60.  
  61. IF RND < .4 THEN 'Optional Opener <><><><><><><><><><><><><><><><><><><><><><><><><>
  62.  
  63.     RESTORE Chat_Opener: GOSUB DataCount 'Count the line openers
  64.     'Get_Open:
  65.     RESTORE Chat_Opener: FOR D = 1 TO RND * C + 1: READ D$: NEXT: D = 0 ': IF D$ = "" OR D$ = "XXX" GOTO Get_Open
  66.  
  67.     IF RIGHT$(D$, 3) <> "..." THEN D$ = D$ + " "
  68.     Chat$ = D$ + LCASE$(Chat$)
  69. END IF '<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
  70.  
  71.  
  72.  
  73. IF RND < .4 THEN 'Optionally, pilot addresses Commander <><><><><><><><><><><><><><>
  74.     IF LEFT$(Chat$, 2) <> "I " THEN Chat$ = LCASE$(Chat$)
  75.     Chat$ = "Commander, " + Chat$
  76. END IF '<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
  77.  
  78.  
  79. RESTORE Tech_Adj: GOSUB DataCount 'Count the adjectives
  80. 'Get_Adj:
  81. RESTORE Tech_Adj: FOR D = 1 TO RND * C + 1: READ D$: NEXT: D = 0 ': IF D$ = "" OR D$ = "XXX" GOTO Get_Adj
  82.  
  83. Chat$ = Chat$ + D$ + " " '================================================================
  84.  
  85.  
  86. IF RND < .6 THEN 'Optional middle noun  <><><><><><><><><><><><><><><><><><><><><><>
  87.     RESTORE Tech_Noun_1: GOSUB DataCount
  88.     'Get_Noun1:
  89.     RESTORE Tech_Noun_1: FOR D = 1 TO RND * C + 1: READ D$: NEXT: D = 0 ': IF D$ = "" OR D$ = "XXX" GOTO Get_Noun1
  90.  
  91.     Chat$ = Chat$ + D$ + " "
  92. END IF '<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
  93.  
  94.  
  95. RESTORE Tech_Noun_2: GOSUB DataCount
  96. 'Get_Noun2:
  97. RESTORE Tech_Noun_2: FOR D = 1 TO RND * C + 1: READ D$: NEXT: D = 0 ': IF D$ = "" OR D$ = "XXX" GOTO Get_Noun2
  98. Chat$ = Chat$ + D$ + " " '================================================================
  99.  
  100. IF INSTR(Chat$, "binary computer") GOTO Tech_Talk 'Avoid really silly Tech Things
  101. IF INSTR(Chat$, "continuous computer") GOTO Tech_Talk
  102.  
  103. RESTORE Chat_Closer: GOSUB DataCount 'Count the line enders
  104. Get_Close:
  105. RN = RND * C + 1: IF RN > C - 3 AND RND < .92 GOTO Get_Close 'Limit occurrences of silly closers
  106. RESTORE Chat_Closer: FOR D = 1 TO RN: READ D$: NEXT: D = 0 ': IF D$ = "" OR D$ = "XXX" GOTO Get_Close
  107.  
  108. IF INSTR(Chat$, "seems") > 0 AND INSTR(D$, "seems") > 0 GOTO Get_Close 'Don't have "seems" twice in a line
  109. IF INSTR(Chat$, "I believe") > 0 AND INSTR(D$, "seems") > 0 GOTO Get_Close 'This is also dumb
  110. IF INSTR(Chat$, "I think") > 0 AND INSTR(D$, "seems") > 0 GOTO Get_Close
  111.  
  112. Chat$ = Chat$ + D$ '======================================================================
  113.  
  114. 'Maybe add an optional closer-closer...
  115.  
  116. IF RND < .4 THEN Chat$ = Chat$ + " again"
  117. IF RND < .5 THEN Chat$ = Chat$ + "." ELSE Chat$ = Chat$ + "!" 'And there's your Pilot's dialogue!
  118.  
  119.  
  120.  

By the way, can someone explain why, when I enable the DEFINT A-Z at the top, the end-of-data marker (XXX) will show up in some of the lines of text?  I know I should know this, but...
Thanks.
« Last Edit: November 20, 2018, 01:26:35 pm by SirCrow »
I may not always finish what I've started....

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Sci-Fi Techno-Babble Generator
« Reply #1 on: November 20, 2018, 01:55:30 pm »
Very cool... I particularly like the 'comedy' remarks, "gone all screwy","acting funny","on the fritz" - I was expecting "Star Trek" type comments but was pleasantly surprised by the 'slang'... Well done!

J
Logic is the beginning of wisdom.

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Sci-Fi Techno-Babble Generator
« Reply #2 on: November 20, 2018, 02:03:10 pm »
You're taking a fraction (RND) and multiplying by an integer then assigning it to the variable D. D will be rounded up if you define it as an integer by DEFINT A-Z, which means it will go as high as 8, which is the XXX in the noun2 data field.

Here, try running this example with and without DEFINT A-Z

Code: QB64: [Select]
  1. DEFINT A-Z
  2. FOR d = .9 TO 5: PRINT d: NEXT
  3. FOR i = 1 TO 4.9 ' Will print to 5 if DEFINT A-Z is utilized, to 4 if not.
  4.     PRINT i
  5. FOR i = 1 TO 5
  6.     PRINT i

See what I mean?

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline SirCrow

  • Forum Regular
  • Posts: 144
    • View Profile
Re: Sci-Fi Techno-Babble Generator
« Reply #3 on: November 20, 2018, 02:14:52 pm »
You're taking a fraction (RND) and multiplying by an integer then assigning it to the variable D. D will be rounded up if you define it as an integer by DEFINT A-Z, which means it will go as high as 8, which is the XXX in the noun2 data field.

Here, try running this example with and without DEFINT A-Z

Code: QB64: [Select]
  1. DEFINT A-Z
  2. FOR d = .9 TO 5: PRINT d: NEXT
  3. FOR i = 1 TO 4.9 ' Will print to 5 if DEFINT A-Z is utilized, to 4 if not.
  4.     PRINT i
  5. FOR i = 1 TO 5
  6.     PRINT i

See what I mean?

Pete

Thanks, Pete.  I had already figured it had to be the fraction/integer thing;  I just hadn't yet located the exact one.  I see now that it's at the FOR-NEXT loops.
I may not always finish what I've started....

Offline SirCrow

  • Forum Regular
  • Posts: 144
    • View Profile
Re: Sci-Fi Techno-Babble Generator
« Reply #4 on: November 20, 2018, 02:19:48 pm »
Very cool... I particularly like the 'comedy' remarks, "gone all screwy","acting funny","on the fritz" - I was expecting "Star Trek" type comments but was pleasantly surprised by the 'slang'... Well done!

J

Thanks!  Glad you liked it.  Keep running it and eventually you'll see the funniest of the funny, methinks. I've limited their usage, as it seems a bit inappropriate that a space pilot on a serious mission should talk that way.  Only slightly vulgar, mind you.
I may not always finish what I've started....

Offline SirCrow

  • Forum Regular
  • Posts: 144
    • View Profile
Re: Sci-Fi Techno-Babble Generator
« Reply #5 on: November 20, 2018, 08:06:51 pm »
It's so funny, while testing the technical-jargon generator, I have it set to display the various (make-believe) voice-to-text messages much more frequently than it'll be once testing is done.  It's all Commander this, Commander that in rapid succession.  I'd hate to be that commander.  No doubt he/she would either quit very early or just start blasting his/her own pilots' ships to bits.
Anyway, I hope to upload this new version of StarBlast pretty soon.
I may not always finish what I've started....

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Sci-Fi Techno-Babble Generator
« Reply #6 on: November 20, 2018, 08:23:34 pm »
I'm sure President Trump could sympathize. Have you considered downloading some sort of text to speech app and shelling the messages?

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline SirCrow

  • Forum Regular
  • Posts: 144
    • View Profile
Re: Sci-Fi Techno-Babble Generator
« Reply #7 on: November 20, 2018, 11:03:10 pm »
I'm sure President Trump could sympathize. Have you considered downloading some sort of text to speech app and shelling the messages?

Pete

That's quite an idea.  If I can find something entirely free and easy to use, I may just do that.  Thanks.
I may not always finish what I've started....

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Sci-Fi Techno-Babble Generator
« Reply #8 on: November 20, 2018, 11:17:10 pm »
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Sci-Fi Techno-Babble Generator
« Reply #9 on: November 20, 2018, 11:31:19 pm »
In Windows, you should be able to use a powershell script with the built in text-to-speech.   

Create a script called "speak.psl"  (PSL for Power Script Language, not ps1 as the number 1.  Sometimes it's hard to tell the difference depending on font.)

Code: QB64: [Select]
  1. param([string]$inputText)
  2. Add-Type –AssemblyName System.Speech
  3. $synth = New-Object System.Speech.Synthesis.SpeechSynthesizer
  4. $synth.Speak($inputText);

Then you can call it from the command line (or QB64 SHELL) with:

.\speak.psl "I'm sorry Dave, I'm afraid I can't do that"
« Last Edit: November 20, 2018, 11:35:32 pm by SMcNeill »
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline SirCrow

  • Forum Regular
  • Posts: 144
    • View Profile
Re: Sci-Fi Techno-Babble Generator
« Reply #10 on: November 20, 2018, 11:47:59 pm »
I'm using Ubuntu.  I'll look into it and come back here for help if I need it.  Thanks.
« Last Edit: November 20, 2018, 11:50:26 pm by SirCrow »
I may not always finish what I've started....

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Sci-Fi Techno-Babble Generator
« Reply #11 on: November 20, 2018, 11:51:19 pm »
The link I provided...

"For Linux or CYGWIN installations, there is a script file (ptts.sh) which provides everything here but supports many speech engines and languages. Run ptts.sh --help to get information on it. Note that under Linux the Microsoft speech engine will not work, another speech engine must be installed. "
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline SirCrow

  • Forum Regular
  • Posts: 144
    • View Profile
Re: Sci-Fi Techno-Babble Generator
« Reply #12 on: November 23, 2018, 03:21:18 am »
The link I provided...

"For Linux or CYGWIN installations, there is a script file (ptts.sh) which provides everything here but supports many speech engines and languages. Run ptts.sh --help to get information on it. Note that under Linux the Microsoft speech engine will not work, another speech engine must be installed. "

Thanks.  I just hope I won't find all of this too daunting.  I do suffer a bit of old dog, new tricks, y'know.  More than a bit, really.
I'm encouraged, though, by the fact that, before I made my really cool Asteroids knock-off, I wouldn't have imagined incorporating multi-layered moving backgrounds in any of my programs.

EDIT: I've installed eSpeak and, without too much trouble, got it to work in my game.  Some people claim that MaryTTS produces much better voices, but I've had much trouble getting that to work.  Also, I have no idea whether my prog. code, as it stands now, would produce speech when run under Windows.
« Last Edit: November 23, 2018, 11:47:49 am by SirCrow »
I may not always finish what I've started....

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Sci-Fi Techno-Babble Generator
« Reply #13 on: November 23, 2018, 06:36:57 pm »
I fully understand the daunting part. That has actually put me off from trying Linux, but I'm getting pressured by Microsoft's transition to their BS app plan.

I'm glad you found a voice solution with eSpeak. That should add some punch to your game. If text to speech was available in the 1980's, I would have had a field day using it.

Please keep us posted n how the project is coming along.

Pete

Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline luke

  • Administrator
  • Seasoned Forum Regular
  • Posts: 324
    • View Profile
Re: Sci-Fi Techno-Babble Generator
« Reply #14 on: November 23, 2018, 06:50:28 pm »
If you're not willing to muck around with that, there's a program called festival that does TTS on Linux. "sudo apt-get install festival" then "festival --tts file.txt".