Skip to content

separate audio for each sentence with corresponding file name #432

Closed Answered by lacorrep
omega3 asked this question in Q&A
Discussion options

You must be logged in to vote

To create a single file for each sentence (01.mp3, 02.mp3...), save your spreadsheet in CSV then run this Python script:

import csv
from gtts import gTTS
# mport time # if you want to add pauses because you are worried

filename = 'my_sentences.csv' # name of the spreadsheet file in CSV format

with open(filename, 'r') as csvfile:
	reader = csv.reader(csvfile)
	for row in reader:
		sentence_number, sentence = row
		gTTS(sentence, lang='en', lang_check=False, slow=False).save(sentence_number+'.mp3')
		# time.sleep(1) # wait 1 second if you are worried

If you know how to code, you could also loop the command line you wrote using the BASH language. If you want to create a single file, I gave…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@omega3
Comment options

@lacorrep
Comment options

Answer selected by omega3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants