I am developing a fun TTS program and I've run into a bit of a problem.
Basically I am bringing in a list of sentences into a database and randomly selecting them, at the same time keeping a database of sentences that have already been used until all of them have been used and then it resets itself. The problem is, 1. I don't like loading these all into an array because of memory purposes. 2. I don't want to have a limitation on how many sentences I can use which is currently 1000 for memory sake. Any advice on this? Code is below
Expand|Select|Wrap|Line Numbers
- 'This is the randomizer for random phrases
- 'If no phrases are found, exit.
- If RandCount <= 0 Then
- Speak "I have nothing to say."
- Exit Function
- End If
- 'Resets the count if all phrases have been used.
- If LastCount > RandCount Then
- For LastLoop = 1 To 1000
- LastPhrase(LastLoop) = ""
- Next LastLoop
- LastCount = 1
- End If
- 'Randomizes phrases and makes sure no repeats happen.
- RANDPHRASE:
- Randomize
- RandGen = Int(Rnd * RandCount + 1)
- If RandGen = 0 Then GoTo RANDPHRASE
- If RandCount > 10 Then
- For LastLoop = 1 To 1000
- If RandomPhrase(RandGen) = LastPhrase(LastLoop) Then
- GoTo RANDPHRASE
- End If
- Next LastLoop
- End If
- Speak RandomPhrase(RandGen)
- RepeatPhrase = RandomPhrase(RandGen)
- If RandCount > 10 And LastCount <= 1000 Then
- LastPhrase(LastCount) = RandomPhrase(RandGen)
- End If
- LastCount = LastCount + 1