Answer the question
In order to leave comments, you need to log in
Python 3 how not to output operations with os, sys, subprocess modules to the console?
One of the code examples that I'm running but don't want to output anything to the terminal:
def j_say(phrase):
os.system('curl "https://tts.voicetech.yandex.net/generate?format=wav&lang=ru-RU&speaker=zahar&emotion=good&key=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -G --data-urlencode "text=' + phrase + '" > j_speech.wav')
os.system('aplay j_speech.wav')
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 133k 0 133k 0 0 496k 0 --:--:-- --:--:-- --:--:-- 496k
Воспроизведение WAVE 'j_speech.wav' : Signed 16 bit Little Endian, Частота 48000 Гц, Моно
Answer the question
In order to leave comments, you need to log in
os, sys, subprocess
subprocess
is controlled via the stderr/stdout options of the Popen class constructor, just by default the output will be merged with the main program. Try this.
Drink for yourself, read about subprocess. There the dock is understandable.
import os,sys,subprocess
def j_say(phrase):
arg = subprocess.Popen(['curl','--basic','pornhub.com'],stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
return arg.stdout.read().decode("cp866")
print(j_say(('abr')))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question