A script for variable tempo for a selected sound sample?

Like a granulator ?