How do I change animation speed to match moving speed

I have an animation called CharacterRotation and I want it to speed up when my character speeds up and slow down when my character slows down. How can I do that with c# code? Any and all help is greatly apreciated

Edit: So far I have this
public class RollAnimationSpeed : MonoBehaviour {

	// Update is called once per frame
	void Update () {

		animation ["CharacterRotation"].speed = PlayerComponent.Speed / 30f;
	}
}

Problem is that I don’t know how to call the PlayerComponent class to this script, if I could do that then I’d be able to do it from there.

The PlayerComponent is probably another Component on the same GameObject as this RollAnimationSpeed script, yes?

If so, use

GetComponent<PlayerComponent>().Speed

Or look at my answer to a similar problem of “how to access another component” - typed question.

Well, to change the animation speed all you have to do is (js example):

var Player : GameObject;

function AdjustSpeed ()
	{
	Player.animation["walk"].speed = 1.0;
	}