AVSpeechUtterance 10% step rate changes - swift

I need to implement AVSpeechUtterance rate change in range from 50% to 150% relative to normal speed with a step of 10%.
The problem is that I can't really find neither absolute, nor relative rate values to build on.
I do know that normal rate value is 0.5. But setting it to 0.6 at least doubles the speed.
Documentation mentions AVSpeechUtteranceMinimumSpeechRate and AVSpeechUtteranceMaximumSpeechRate, but I fail to understand how to make use of it since I can't even access it.
Any help is appreciated!

Related

Why is the volume coming from -80db to 0 - not even starting at 0?

I'm very new to sound. I've never explored this area in my whole life.
I thought decibels was a measure starting at 0.
But in Unity, it starts at -80db and and "0db" it seems it's the "100%" level volume.
Moreover, when I change the sound to -40db it's not "half-way" between -80db and and 0 it seems it's much closer to -80db. So the user hears nothing when it's "half-way":
I couldn't find anywhere how to setup sound properly, and how to make the user choose "properly" the sound (= good scale).
Any idea / Unity valuable sample for this?
From Wikipedia -> Decibel
dB is a relative unit of measurement [...] It expresses the ratio of two values
This is very common for Audio Mixers and Amps that 0 means 100% of the configured Pre-Gain (-> in this case the input volume of your individual AudioSources).
Why? -> The given dB are just the additional "multiplicator" (as said it is a logarithmic ratio between two values).
Usually as an Audio manager you first configure all Pre-Gains in a way that basically everything has more or less the same absolute volume if all mixer sliders are at 0.
Then you start to actually mix them according to your needs and only move certain volumes up or down to increase or decrease the volume by a certain factor. (Except for fading it is usually pretty uncommon to actually pull a slider down to the minimum - usually you rather Mute the channel)
0dB just means 1:1 => Don't change.
e.g. 6dB means about 2:1 => twice as loud as the input volume
e.g. -6dB means about 1:2 => half as loud as the input volume
e.g. 20dB means about 10:1 => Ten times as loud as the input volume
e.g. -80dB means 1:10000 => So 0.0001 of the input volume
So the -80 is chosen a little bit arbitrary .. it could as well be -60 (=>factor of 0.001) or -100 (=> factor of 0.00001). "It doesn't really matter!". At a certain point the volume is simply so low that you won't hear it anymore depending on what the default maximum output of your Amp is and how precise you need the output to be.
You can e.g. use this dB calculator to check what dB value results in what actual factor.
For a better explanation of the dB measure itself see also e.g. these posts and What's the minimum decibel value?

How to make an reinforcement learning agent learn an endless runner?

I'm tried to train a reinforcement learning agent to play an endless runner game using Unity-ML.
The game is simple: an obstacle is approaching from the side and the agent has to jump at the right timing to overcome it.
As the observation, I have the distance to the next obstacle. Possible actions are 0 - idle; 1 - jump. Rewards are given for longer playtime.
Unfortunately, the agent fails to learn to overcome even the 1st obstacle reliable. I guess this is due too high imbalance on the two actions as the ideal policy would be doing nothing (0) most of the time and jump (1) only at very specific points in time. Additionally, all actions during a jump are meaningless since the agent cannot jump while in the air.
How can I improve the learning such that it convergence nevertheless? Any suggestions what to look into?
Current trainer config:
EndlessRunnerBrain:
gamma: 0.99
beta: 1e-3
epsilon: 0.2
learning_rate: 1e-5
buffer_size: 40960
batch_size: 32
time_horizon: 2048
max_steps: 5.0e6
Thanks!
It's difficult to say without seeing the exact code that's being used for the reinforcement learning algorithm. Here are some steps worth exploring:
How long are you letting the agent train? Depending on the complexity of the game environment, it very well may take thousands of episodes for the agent to learn to avoid its first obstacle.
Experiment with the Frameskip property of the Academy object. This permits the agent to only take an action after a number of frames have passed. Increasing this value may increase the speed of learning in more simple games.
Adjust the learning rate. The learning rate determines how heavily the agent weights new information versus old information. You're using a very small learning rate; try increasing it by a couple decimal places.
Adjust epsilon. Epsilon determines how often a random action is taken. Given a state and an epsilon rate of 0.2, your agent will take a random action 20% of the time. The other 80% of the time, it will choose the (state, action) pair with the highest associated reward. You can try reducing or increasing this value to see if you get better results. Since you know you'll want more random actions in the beginning of training, you can even "decay" epsilon with each episode. If you start with an epsilon value of 0.5, after each game episode is completed, reduce epsilon by a small value, say 0.00001 or so.
Change the way the agent is rewarded. Instead of rewarding the agent for each frame it stays alive, perhaps you could reward the agent for each obstacle it successfully jumps over.
Are you sure that the given time_horizon and max_steps provide enough runway for the game to complete an episode?
Hope this helps, and best of luck!

AnyLogic: How to set pedestrian comfortable speed beyond the range

I got the problem of the pedestrian library. I would like to use the pedestrian library to simulate the behavior of the vehicle, therefore, I would like to set the comfortable speed of the agent to be, say 70km/h. However, there is an error saying the speed has to be within [0mps, 10mps]. Is there any way to set whatever speed I want?
Thank you,
Jiannan
First why don't you use the road traffic library? But you must have your reasons.
You can't change the maximum speed value, but what you can do, which is not a very elegant solution, but a solution nonetheless, is to change the time scale of your model. There is no direct option for that, so you basically have to create your own clock that runs your way.
So for instance, if you want your car to move at 20mps, you choose 10 mps as the comfortable speed and you have the transformation customTime(time())=0.5*time(), where custom time is your own function.
So every time 1 second passes in the simulation, in your custom clock only 0.5 seconds will pass... You just have to take care of the statistics you are collecting so they fit your time scale.
Also, you will have to change everything according to your clock in your model, because Anylogic will continue showing you things in normal seconds.
Hope that helps :)

How to detect ultrasonic range sensor is out of range or not?

I am using jsn-srf04t ranging sensor (25cm to 5m range) I want to know when it is going out of range(when under 25cm)
The problem is when it goes under 25 cm, the sensor output sometimes goes to (90cm to 95cm or 100cm to 120cm) and this cause undetectability of that it is really out of range or not!
Is there any solution?
This question is not directly related, but I thought I post a suggestion/answer anyway.
SRF04's can detect the distances as small as 3 cms. Please measure the width of the output echo pulse using an oscilloscope. It can be from 100uS to 18mS and if there is no object within its range, the echo pulse is 36ms.
If the measured pulse width from the oscilloscope is agreeing with what you say, then presumably the SRF04 is faulty, or there is a problem with its mounting etc.
If the width of the pulse is measured in uS, then dividing by 58 will give you the distance in cm, or dividing by 148 will give the distance in inches.
The SRF sensors can be triggered as fast as every 50mS, or 20 times each second. You should wait 50ms before the next trigger to ensure the ultrasonic "beep" has faded away and will not cause a false echo on the next ranging.
Otherwise, check your timer configuration. Ensure that it can measure a pulse in the order of hundreds of microseconds with at least a resolution of tens of microseconds.
If you are using this, then perhaps you are at the lowest possible level.

Why are my accelerometer readings so slow?

Somewhere in the documentation they mentioned 400 Hz. Nice figure, but I end up getting something less than 100. Even on the latest, coolest, most awesome iPhone 4. And I'm not doing anything except incrementing a counter (ivar) and assigning the value to a label. Can't imagine this is the bottleneck.
I set the frequency to the maximum possible (very small number, like 1.0/10000). It is supposed to be capped to the max whatever the hardware supports.
You can adjust that frequency - see my answer.