Noob question - Input text file? #1101
Replies: 12 comments 18 replies
-
If it is reading the name of the text file. Then you are already giving it your file name as input. You may change a little bit of code to instruct it to take your text file as input. And there may be a gui (local server) present. |
Beta Was this translation helpful? Give feedback.
-
I'm also interested in this. For example, I want to synthesize the phrase "hello world". First, I place the phrase into a text file: $ echo "Hello world" > hello.txt Then I want Coqui to synthesize the speech. I imagine a command like this: $ cat hello.txt | tts --model_name tts_models/en/vctk/vits --speaker_idx p225 Or this: $ tts --model_name tts_models/en/vctk/vits --speaker_idx p225 --input_file hello.txt The results would be a WAV file containing the speech "hello world" NOT "hello.txt" I understand that it's possible to synthesize "hello world" with the I've tried: $ cat example.txt | tts --model_name tts_models/en/vctk/vits --speaker_idx p225
$ tts --model_name tts_models/en/vctk/vits --speaker_idx p225 --text $(< example.txt)
$ cat example.txt - | tts --model_name tts_models/en/vctk/vits --speaker_idx p225 --text - But none of these "tricks" work. |
Beta Was this translation helpful? Give feedback.
-
Here's a work-around, at least for now, that's working for me.
tts-server --model_name tts_models/en/vctk/vits --port 8080
It's not my ideal workflow, but this does the trick. Hope that helps. |
Beta Was this translation helpful? Give feedback.
-
I have written a small bash script just for that, you might want to have a look, |
Beta Was this translation helpful? Give feedback.
-
In the future, will it be possible to use a text file as input? |
Beta Was this translation helpful? Give feedback.
-
Just use cat my_text_file.txt | xargs -0 tts --model_name "tts_models/en/ljspeech/tacotron2-DDC" --out_path "out_tacotron2.wav" --text This puts the content of Note that I found out |
Beta Was this translation helpful? Give feedback.
-
go to server/template/index.html
then launch server |
Beta Was this translation helpful? Give feedback.
-
Also looking for a command line solution on Windows which takes a text file as input (as opposed to modifying the server ui to accept a file input). |
Beta Was this translation helpful? Give feedback.
-
would also like to see it accept a text file as input. |
Beta Was this translation helpful? Give feedback.
-
On macOs, you can do the following
|
Beta Was this translation helpful? Give feedback.
-
I also want to use txt ile as input , but when i giuve the path it reads the path as input text , did ypu found the solution yet |
Beta Was this translation helpful? Give feedback.
-
Added an ad-hock "enhancement". Changes:
diff --git a/TTS/bin/synthesize.py b/TTS/bin/synthesize.py
index b86252ab..8f62150c 100755
--- a/TTS/bin/synthesize.py
+++ b/TTS/bin/synthesize.py
@@ -170,7 +170,18 @@ def main():
help="model info using query format: <model_type>/<language>/<dataset>/<model_name>",
)
- parser.add_argument("--text", type=str, default=None, help="Text to generate speech.")
+ parser.add_argument("--text",
+ type=str,
+ default=None,
+ nargs='*',
+ help="Text to generate speech."
+ )
+ parser.add_argument("--text_file",
+ type=str,
+ default=None,
+ nargs='*',
+ help="Text-file to generate speech."
+ )
# Args for running pre-trained TTS models.
parser.add_argument(
@@ -224,7 +235,7 @@ def main():
const=True,
default=False,
)
-
+
# args for multi-speaker synthesis
parser.add_argument("--speakers_file_path", type=str, help="JSON file for multi-speaker model.", default=None)
parser.add_argument("--language_ids_file_path", type=str, help="JSON file for multi-lingual model.", default=None)
@@ -313,9 +324,23 @@ def main():
default=None,
help="Voice dir for tortoise model",
)
-
args = parser.parse_args()
+ if args.text_file is not None:
+ if args.text is None:
+ args.text = []
+ for file in args.text_file:
+ with open(file, 'r', encoding = 'utf8') as f:
+ args.text += f.read().splitlines()
+
+ if not sys.stdin.isatty():
+ if args.text is None:
+ args.text = []
+ args.text += sys.stdin.read().splitlines()
+
+ if args.text is not None:
+ args.text = '\n'.join(args.text)
+
# print the description if either text or list_models is not set
check_args = [
args.text,
@@ -482,7 +507,10 @@ def main():
)
elif model_dir is not None:
wav = synthesizer.tts(
- args.text, speaker_name=args.speaker_idx, language_name=args.language_idx, speaker_wav=args.speaker_wav
+ args.text,
+ speaker_name=args.speaker_idx,
+ language_name=args.language_idx,
+ speaker_wav=args.speaker_wav
)
# save the results |
Beta Was this translation helpful? Give feedback.
-
I hope this is a good place to ask this, and maybe some other noobies might also not be able to figure this out as well.
I just installed TTS from PyPI using "PIP install TTS" and doing some tests from the terminal interface, but I cannot figure out how to feed the text file I want it to read. I can get to read a short piece of inline text, but it doesn't seem able to take an input text file as an argument? It just reads the name of the text file I give it. I can't find anywhere in the documentation that describes how to do this.
or is there some other UI other than the terminal interface that I should be trying? There has to be a way other that typing out the text to be spoken in it's entirety when invoking the TTS command from CMD.
Thanks,
Beta Was this translation helpful? Give feedback.
All reactions