@Toostupefiant Definitely learn to use arrays, in particular, [tabwrite] and [tabread}. Make 2 arrays, one to save the segment start indexes and one to hold their lengths. Next, decide what the minimum and maximum length of each segment should be, in number of samples. With these numbers at hand, you can use [random] to generate a random segment length. When you load the sound file, save its length to use for comparison later.
Now, to construct a random partitioning of your sound file, start at start index 0 (i.e. the beginning of your sound file) and generate a random length. That defines your first segment, segment #0, but it also tells you what the next start index is, for segment #1. Save each start and length generated this way in your two arrays. Repeat until you've reached or gone past the end of the sound file. Keep track of the number of segments you generate because you'll need that for when you play them back at random. Pick a number less than or equal to the number of segments, look up its start in the start array and its length in the length array. Pass them to whatever you use for playback.
If you can manage that, then you'll probably want to protect against uselessly short last segments. That's a matter of looking at how much is left after each step of segment definition, and making some adjustment if it's less than your max + min segment length. I'm being vague about the adjustment because it just depends what compromise you want, e.g. you could just decide to ignore the last segment.