footstep audio script for player animation

i’ve seen some scripts of 2D Game play Tutorial Project file . and used it to my game character .and it seems very simple but i can’t imagine what’s wrong with it . after hit play the game and when my character walk,footstep sound is normal but when player run,the footstep sound can’t stay with foot step speed and slower . any body help me for this scripts . I used this script .

var audioStepLength = 0.3; 
var walkSounds:AudioClip[];

function Start () { 
  var controller : CharacterController = GetComponent(CharacterController);
  while (true)
  {
    if (controller.isGrounded && controller.velocity.magnitude > 0.3)
    {
        audio.clip = walkSounds[Random.Range(0, walkSounds.length)];
        audio.Play();
        yield WaitForSeconds(audioStepLength);
    }
    else
    {
        yield;
    }
  }
}

just like that . thanks

Create a function that shortens the interval as the character speed increases. Supposing the character velocity is between 0 and 8, you could use something this:

var walkSounds:AudioClip[];
var minInterval = 0.1; // min interval between steps
var maxVelocity = 8; // max character speed
var bias = 1.1; // the greater the bias, the lesser the step delay variation

function Start () { 
  var controller : CharacterController = GetComponent(CharacterController);
  while (true){
    var vel = controller.velocity.magnitude;
    if (controller.isGrounded && vel > 0.2){
        audio.clip = walkSounds[Random.Range(0, walkSounds.length)];
        audio.Play();
        var interval = minInterval*(maxVelocity+bias)/(vel+bias);
        yield WaitForSeconds(interval);
    }
    else
    {
        yield;
    }
  }
}