aws-samples / amazon-sumerian-hosts

Amazon Sumerian Hosts (Hosts) is an experimental open source project that aims to make it easy to create interactive animated 3D characters for Babylon.js, three.js, and other web 3D frameworks. It leverages AWS services including Amazon Polly (text-to-speech) and Amazon Lex (chatbot).
MIT No Attribution
174 stars 80 forks source link

Sound is weak and muffled #55

Open IvanFarkas opened 3 years ago

IvanFarkas commented 3 years ago

The sound is very weak and muffled.

How do I make it loud and clear? Compare to generated wav files it pales in comparison.

IvanFarkas commented 3 years ago

I thought about this. It's using THREE.PositionalAudio(), so getting closer it becomes louder, but it's still very dull and muffled. I was able to make it louder by calling setRefDistance() and setDirectionalCone() functions in src/three.js/awspack/TextToSpeechFeature.js:

// Create positional audio if there's an attach point
result.threeAudio = new THREE.PositionalAudio(this._listener);

result.threeAudio.setRefDistance(5);
result.threeAudio.setDirectionalCone(90, 90, 0.5);
console.log('Audio made louder!');
jkerste commented 3 years ago

Hey @IvanFarkas, that is correct for the positional audio. There is existing functionality to support creating a THREE.Audio which is a global audio source, when the _attachTo property is undefined. However, this value currently defaults to the host object itself when not specified in the TextToSpeechFeature constructor.

if (this._attachTo !== undefined) {
    // Create positional audio if there's an attach `point`
    result.threeAudio = new THREE.PositionalAudio(this._listener);
    this._attachTo.add(result.threeAudio);
} else {
    // Create non-positional audio
    result.threeAudio = new THREE.Audio(this._listener);
}

An option could be added to the TextToSpeechFeature constructor, like isGlobal, that would indicate when a non-positional audio source should be used for the speech.

IvanFarkas commented 2 years ago

Hi @jkerste. I like your isGlobal idea.

jkerste commented 2 years ago

Hey @IvanFarkas this feature is now merged into mainline. You can set up the TextToSpeech as "global audio" by modifying the options passed into the TextToSpeech constructor like:

// Set up text to speech
host.addFeature(HOST.aws.TextToSpeechFeature, false, {
  scene,
  attachTo: audioAttachJoint,
  isGlobal: true,
  voice,
  engine,
});