Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SAM native QB64PE speech synthesizer (port from C attempt 2)
#3
With the first attempt, I just pointed the ai at a repository - gave it some URLs and told it to go make a QB64PE version. It took a couple tries but eventually I got it to produce a program, albeit one that was greatly simplified and the sound part didn't work. 

I thought that the rules for parsing grammar and phonemes and figuring out which sounds to break up each word into is more important, so this time I fed the ai all the C code myself, module by module, instead of asking it to just "go look at this and make it in QB64", so that it wouldn't take shortcuts or just create a skeleton without the real logic. 

The thing is, these free ai agents are very limited with regard to how much code they produce. If it's more than 100 lines, chances are it'll just produce the first 100 lines and stop. You can ask it to output the rest and sometimes it will, sometimes it won't! Sometimes it'll output the rest but it doesn't match the first half! So I broke the code down to bite size pieces so the whole thing would get converted. But then you have to piece it all back together. 

Also, C programs are crazy, they have these header files (I never understood the point of those, why don't they just put all that stuff at the top of the code file??) and stuff in different modules. But then you have multiple modules with variable declarations and values being initialized at the top outside of any functions or subs. When do those initializations run, in a different module and not inside any routine?? It makes no sense. So I converted it all and put all in one file (so you only have to load one BAS file and run - nice and simple!) with all the types and global declarations at the top, followed by any global variable initialization, then next the code that fires off Main (in this case it just fires off a couple test routines), and lastly all the subs and functions. 

So all the logic should be present, but it's gonna take going through and cleaning up all the dumb mistakes the ai made, like even though I said convert to QB64PE 4.x and told it the URL of the wiki and said go here and learn the language, it doesn't always do what you ask 100% and falls back on old knowledge, like it might assume QB64PE doesn't have a command equivalent to "continue" in C (it does, _CONTINUE) and as a workaround it replaces all the continue commands with GOTO statements, so I searched through the code for all those and replaced them with _CONTINUE. Not hard, just tedious.

Another thing I had to fix was these array assignments. In the C code they have these arrays declared as constants, with the values assigned in place right there in the declaration. In the QB64 version the arrays are variables that get populated from data statements (or just hardcoded). Some of the values in C were in hex notation, but the ai didn't always 100% convert all the values to QB64's hex notation right. So that was fixed with more search & replace. Dumb stuff like that.

In another places the ai completely mangled the translation of an array (I'm not 100% sure but it appears to be mapping ASCII codes to something, maybe phonemes or grammar rules). Often when the ai makes a mess, you can just look back at the original C code and figure it out to manually fix it, but I'm not familiar enough with C to understand what it's doing in this case - it looks like it's assigning each value using bitwise AND or OR combinations, just really weird. Some of this stuff will take effort that I don't have the patience or time for right now. Maybe I'll figure it out later, maybe someone with some C knowledge will know right away. 

Anyway, I figure the first thing to do is to just get it so that the IDE stops complaining about syntax errors. With the first version, that took maybe 20 minutes. This one will probably take more of an effort. I went as far as I could as time allows, but it's a bit much for me to complere right now and I have other projects further along. For this, the important part was to make sure all the logic is present, so then we can just plug away and hammer it into shape! So here we have it, I'm throwing it over the wall for someone, anyone, looking for a challenge or just a puzzle to complete, LoL!
Reply


Messages In This Thread
RE: SAM native QB64PE speech synthesizer (port from C attempt 2) - by madscijr - 04-04-2025, 11:36 PM



Users browsing this thread: 1 Guest(s)