Request assistance with truncating/trimming a string in an automator action used to create text-to-speech audio files from a text selection ranging from 30 or so characters to 800+, which is too long for a file name.
In short, I am trying to truncate a string to 30 characters and pass that to the "Text to Audio File" action as the file name.
Basic workflow is:
Select text Initiate following Automator Action via Services Menu
- "Set Value of Variable" to input (e.g. selected text) and define as TextToSpeech
- "Set Value of Variable" to input (e.g. selected text) and define as FileName
- "Get Value of Variable" FileName
"Run AppleScript"
on run {input, parameters} set theResult to input as string set finalResult to input as string set txtLength to (length of theResult) if txtLength > 30 then set finalResult to (characters 1 thru 30 of theResult) as string end if return finalResult end run
"Set Value of Variable" input (e.g. selected text) and define as FileName
- "Get Value of Variable" TextToSpeech
- "Text to Audio File" with Save As: set to "FileName"
- "Encode to MPEG Audio"
Any assistance/suggestions is greatly appreciated!
Regards,
Zephyr