Jump to content
IGNORED

bB AtariVox Support, Part 2... Basic Voice Functionality


RevEng

Recommended Posts

bB AtariVox Support, Part 2... Basic Voice Functionality

 

The AtariVox is capable of quite good sounding speech, but getting good speech out of it is a bit of an art.

 

In this part, I'll take a look at how to get basic voice functionality out of the AtariVox; following the steps in this post will produce output on par or only slightly better than basic text to speech systems, like SAM, Speak'N'Spell, etc.

 

Just keep in mind that AtariVox can do better than this; I plan to follow-up with another post, with some tips on how to get the AtariVox to sound more natural.

 

 

 

Making Phrases

 

Human speech in any language is made up of atomic sounds called phonemes.

 

To make the AtariVox speak, instead of sending it english letters, you send it phoneme codes. Because it uses phoneme codes, AtariVox doesn't need to guess if an E is silent, or if a particular C sounds like an S or a K; you're sending it all the information it needs to pronounce the sound.

 

The phonemes that AtariVox can say can be found on page 15 of the SpeakJet manual (SpeakJet is the Vox chip in AtariVox) along with the code number for each phoneme.

 

There are a few ways one can determine which phonemes are required to say any particular word...

 

  • The SpeakJet creators, Magnevation, have provided a dictionary of common words and their phoneme composition. Taking the phonemes from the dictionary, you can look up their codes in the SpeakJet manual, and build up a phrase. The dictionary has a very limited number of words, so often you'll be taking phonemes from words with similar sounds. Yes, this is twice as tedious as it sounds.
     
  • Magnevation has also provided a Windows utility, called the Phrase-a-lator, that will take typed in words and sentences and break them into phoneme codes.
     
    Using Phrase-a-lator is definitely less tedious than manual entry, but since Phrase-a-lator uses the same limited dictionary from the manual method, there are many words it doesn't understand.
     
  • batari has created a cross-platform utility called Speak To Me, that can look up your phrase in the SpeakJet dictionary. If a word in the phrase doesn't exist, Speak To Me runs through an algorithm that will attempt a best guess at the phoneme code breakdown.
     
  • I've created a utility called speakalator that operates similar to Phrasealator for Unix platforms. It incorporates batari's code, so it will make a best guess if a word isn't in the dictionary.

 

...I invite you to try to use all of these methods, and find the technique that works best for you.

 

Running the phrase "game over" through batari's utility or the Phrase-a-lator provides the following codes, which we'll use for our example code in the next section: 08 b2 9a 8c 08 89 07 a6 97

 

 

Making AtariVox Say Our Phrase

 

Alex Herbert's SpeakJet driver will do most of the heavy lifting for us. Here's a minimal example of how to get the AtariVox to say our "game over" phonemes...

 

 rem ** include the driver
 asm
 include "speakjet.inc"
end

 rem ** The AtariVox driver requires 2 consecutive bytes of ram.
 dim speech_addr=a
 dim speech_addr2=b

 rem ** Point the AtariVox at the "game over" data!
 asm
 SPEAK data_gameover
end

mainloop
 scorecolor=$0f
 drawscreen
 goto mainloop

 rem ** The SPKOUT routine needs to happen each frame. (or every other frame
 rem ** depending on how many non-voiced codes you use.) The easiest way
 rem ** get it to update with each frame in bB is to just stick it in vblank...
 vblank
 asm
 SPKOUT temp1
end
 return

 rem ** the data ideally starts with 31 to reset the speech frequency, etc.
 rem ** it must end with a 255 end-marker, or else bad things will happen.
 data data_gameover
 31
 $08, $b2, $9a, $8c, $08, $89, $07, $a6, $97
 255
end

 

And that's it!

 

At the bottom of this post I've included sample code that plays more than one sound... The phoneme codes in the sample are courtesy Alex Herbert, lifted directly from his assemebly language demo.

 

 

Points Worth Noting

 

While using the AtariVox Voice Function is straightforward, there are a few things to keep in mind:

  • Stella does not emulate the AtariVox Voice function, but instead can send the codes to a real AtariVox attached to a special low-voltage serial port on your PC. There used to be a USB AtariVox connector, but its not available for sale presently. Another possibility is to connect to the AtariVox with a special TTL level serial port.
     
  • AtariVox speech goes into a buffer, so if you send it a bunch of phrases in a short period of time they'll queue up and it will say all of them. If you want your phrases to interrupt each other, begin your phrases with the command to clear the speech buffer...
     
     data gameover
     "\0RX" ; stop speaking and clear the buffer
     $08, $b2, $9a, $8c, $08, $89, $07, $a6, $97 ; game over
     $ff ; end of data
    end
    


 

 

Lastly, AtariVox is the creation of Richard Hutchinson, and the drivers were created by Alex Herbert. All of your thanks should go to these guys. I know mine does!

 

avoxvoice.zip

  • Like 3
  • Thanks 1
Link to comment
Share on other sites

Hm, sorry to ask this, but I am bit confused. To I have to have a real AtariVox to get this working with Stella? Thanks

That's an excellent question, Diogo - I'll update the main post with this information.

 

Yes. For Vox operation (unlike the EEPROM access) stella needs a real AtariVox attached to it through a special low-voltage serial port.

 

At one time the AtariAge store carried a special USB AtariVox that had the port built-in, but I don't think they do now. :(

Link to comment
Share on other sites

Hm, sorry to ask this, but I am bit confused. To I have to have a real AtariVox to get this working with Stella? Thanks

That's an excellent question, Diogo - I'll update the main post with this information.

 

Yes. For Vox operation (unlike the EEPROM access) stella needs a real AtariVox attached to it through a special low-voltage serial port.

 

At one time the AtariAge store carried a special USB AtariVox that had the port built-in, but I don't think they do now. :(

 

Hm too bad. I do synthesized voices once in a while at the audio recording studio I work at and I am really thinking about getting an AtariVox to hook it up with our gear (we already have a 2600 in there). Now that we will be able to program for the AtariVox with Visual bB, things couldn't be easier!

 

I read in the other thread that maybe Ax will produce some... hope that really happens, I'll probably get one! Maybe he could also run some USB versions ;)

Link to comment
Share on other sites

I read in the other thread that maybe Ax will produce some... hope that really happens, I'll probably get one! Maybe he could also run some USB versions ;)

Yeah, that would be cool. I'd buy one!

 

Failing that, with a small bit of modification you could take a cheap USB serial port like this and it would be able to drive a standard AtariVox too.

  • Like 1
Link to comment
Share on other sites

Hm, sorry to ask this, but I am bit confused. To I have to have a real AtariVox to get this working with Stella? Thanks

As mentioned above, yes, you need a real device to get sound output. There was initially some work on adding SpeakJet emulation to Stella (ie, the chip that does synthesized sound in the AVox), but we couldn't get past several major hurdles. And since sound programming, or anything sound related, aren't my strong area, the idea was pretty much shelved.

 

You don't need an AVox or SaveKey for EEPROM access, though; access to this part of the device is emulated. In fact, even if you do have the actual hardware, access is still emulated - it never touches the EEPROM at all. Support for the AVox is kind of weird in Stella. You need actual hardware for sound, as we couldn't properly emulate it. But we don't touch the EEPROM at all, because the required code to do isn't released under the GPL, and can't be included in Stella.

  • Like 1
Link to comment
Share on other sites

I sent my remaining batch of USB interfaces to Glenn a while back, so hopefully either he or Axe will start sellling them in the future (I'll let Axe have the PCB and firmware files if he wishes to make those too).

 

It's basically just a USB to serial convertor (based on the FT232R), but also powers the AVox and has the EEPROM wired through too.

 

Any adaptor can be made to work. You would just need to steal 5V from the USB to power the unit.

 

This is a good one. All the connections are easy to get at.

 

BTW, if you double click on the phonemes in PhraseAlator, they are entered into the say data window. I find it quicker to make new words that way.

Edited by Richard H.
  • Like 3
Link to comment
Share on other sites

  • 2 months later...
  • 4 weeks later...
  • 1 year later...

The pressure is on! :) AA member the.golden.ax is offering real Atarivox hardware to AA members that have previously published games in the AA store to borrow one for development purposes (see his post here: http://www.atariage....x/#entry2715244) and he has agreed to let me borrow one. He's not selling them, it's strictly for development to try and spur development of Avox compatible games. After reading this post I'm ready to dive in and see what I can figure out. He has USB and DB9 versions available, I opted for the USB version to make it easier to try and develop on the PC. Sorry RevEng, but you may be getting a few more posts from me in the future with questions. I'm excited about working with the Avox. :)

 

EDIT: For clarification, here are the.golden.ax's conditions for asking for a loaner AtariVox:

 

A) You must have at least one completed title for sale on the Atari Age store now (or in the past) - hacks do count.

-= OR have completed title(s) that are available for download on Atari Age in a thread (send link) - hacks don't count =-

 

B) The loaner Vox is not for resale - keep it as long as you need for programming - return it, if / when you are done.

  • Like 1
Link to comment
Share on other sites

That's pretty awesome, but what's the point of no one has an AtariVox? I think there's great potential if people can actually hear it, but if not, then it's just a gimmick.

 

Is AtariAge going to sell AtariVox modules again, like it apparently used to? If the price was reasonable, I'd be very tempted to get one for development purposes, myself.

  • Like 1
Link to comment
Share on other sites

The original units were on sale for a while. There are AA members with AtariVox units.

 

the.golden.ax recently received a lot of mostly assembled units from mos6507. Ax plans to sell them to AA members once they're completed.

 

@Atarius Maximus: bring the questions on! :D

Link to comment
Share on other sites

Reading through this topic again I've got some questions:

 

I read a piece of text that says "low voltage serial port". Does that mean I could fry an AtariVox if I try and connect it to a standard PC serial port?

 

Also, does this thing have the slow, slow latencies of the SaveKey? Meaning my game couldn't be doing fast action AND telling the AtariVox to say "B17 Bomber!"?

Link to comment
Share on other sites

Reading through this topic again I've got some questions:

 

I read a piece of text that says "low voltage serial port". Does that mean I could fry an AtariVox if I try and connect it to a standard PC serial port?

 

I don't know for sure. The 2600 pinouts are different than a standard DB9 serial pinout, so the best case scenario is it won't work. Worst case is you'll be potentially sending +12v and -12v through certain pins, depending on how your PC serial port is implemented.

 

 

Also, does this thing have the slow, slow latencies of the SaveKey? Meaning my game couldn't be doing fast action AND telling the AtariVox to say "B17 Bomber!"?

 

It's not particularly fast, but not as slow as accessing the eeprom.

 

There are two Vox specific calls we use in bB: SPEAK, which sets pointers to the voice data you want to use, and SPKOUT, which sends 1 byte of your voice data to the Vox per call.

 

SPEAK is fast, as it's just setting a few 6502 bytes.

 

SPKOUT needs to be called ~once per frame and takes about 600 cycles. This will fit comfortably into most kernel's spare vblank time (the notable exception here is DPC+). If you need to call SPKOUT from your regular bB code you'll need to factor it in; most kernels have around 2100 free cycles in overscan. (where bB code runs)

  • Like 1
Link to comment
Share on other sites

I don't know for sure. The 2600 pinouts are different than a standard DB9 serial pinout, so the best case scenario is it won't work. Worst case is you'll be potentially sending +12v and -12v through certain pins, depending on how your PC serial port is implemented.

 

Don't connect the AVox directly to your serial port; use a serial-USB converter instead. Take my word on this :)

 

EDIT: It's actually been some time since I hooked this up to my computer, as I originally plugged it in years ago and it's still there :) I might be remembering things incorrectly, and a standard USB-serial converter might not work either. I'm actually using a USB-AVox interface from Richard H. as described in the next post.

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

Some more thoughts around the cycle requirements...

 

I've been looking at doing a pole position voice hack, and it seems that there's only enough free time for the 600 cycles SPKOUT takes in every other vblank frame. (pole position runs some routines during even frames, and others during odd) This led me to evaluate how often you actually need to call SPKOUT. (recall that SPKOUT is responsible for sending 1 byte to the AtariVox every time its called.)

 

Standard practice is to call SPKOUT every frame, which is about every 16.66ms. The routine needs to be called at a shorter interval than the time AtariVox takes to voice the phonemes, otherwise there will be short unnatural breaks or pops between phonemes, as AtariVox stops talking and waits for more data.

 

I looked at my final Game Over example, which sends a lot of extra control bytes to change each individual phoneme pitch and speed, and it sends 18 bytes of data to produce 890ms of speech, for an average speed of 49.4 ms per byte.

 

Using that average as a guideline, I think it's pretty safe to call SPKOUT every other frame, ie. every 33.33ms. Just test and use your ears as a guide. If there are break ups, try changing the voice speed at the beginning of the data so its a bit slower, or use your control bytes more sparingly in the affected areas.

 

Calling SPKOUT every 4th frame may work too, though its more likely to require a combination of slowing the voice down and minimizing non-voiced control data.

 

I added a note about this in the code comments in the first post

Link to comment
Share on other sites

  • 9 years later...
14 hours ago, KevKelley said:

Just curious. Looking at the schematic, instead of using an adaptor, would one just wire a USB to the two pins on the chip and be good to go?

Your question isn't entirely clear. If by "the chip" you mean the speakjet, and by "wire a USB" you mean a plain old USB cable, then the answer is no. Despite being "Universal Serial Bus", USB doesn't communicate like a legacy serial bus does, which is what you need here. (with non-legacy TTL voltage levels)

Link to comment
Share on other sites

On 3/18/2013 at 4:25 PM, Richard H. said:

This is the circuit for the USB to AtariVox interface.

 

The chip also needs programming. This is done through the USB once the circuit is built. You will need to download a programming utility from the FTDI site. I will send you my .ept file (won't let me attach it here).

post-2630-0-83508700-1363638071_thumb.gif

 

3 hours ago, RevEng said:

Your question isn't entirely clear. If by "the chip" you mean the speakjet, and by "wire a USB" you mean a plain old USB cable, then the answer is no. Despite being "Universal Serial Bus", USB doesn't communicate like a legacy serial bus does, which is what you need here. (with non-legacy TTL voltage levels)

I am not that familiar with wiring for USB so looking at the schematic I didn’t know if it was something as simple as plugging two wires onto those two legs (15 and 16) of the chip. I just kind of looked at it quickly last night and wondered if making modifying an AtariVox into a USB AtariVox would be a simple endeavor or a little more to it than that. 

Link to comment
Share on other sites

54 minutes ago, KevKelley said:

I am not that familiar with wiring for USB so looking at the schematic I didn’t know if it was something as simple as plugging two wires onto those two legs (15 and 16) of the chip. I just kind of looked at it quickly last night and wondered if making modifying an AtariVox into a USB AtariVox would be a simple endeavor or a little more to it than that. 

The chip in the schematic is an FT232R, and the schematic is for a stand-alone USB->AtariVox adapter that Richard H created and provided to some developers a long while back. The AtariVox doesn't have the FT232R built into it.

 

A quick an dirty adapter can be built with a $5 TTL USB to Serial 5V adapter and a serial db-9 connector.

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...