Permalink
Browse files

Update config and fix console window flashing (thanks @QDrew!)

  • Loading branch information...
Uberi committed Mar 11, 2017
1 parent 7d3518d commit 695b123f812205f6da16c1665a1905f2fe5cff9a
Showing with 20 additions and 4 deletions.
  1. +2 −2 README.rst
  2. +4 −0 setup.cfg
  3. +14 −2 speech_recognition/__init__.py
View
@@ -17,7 +17,7 @@ SpeechRecognition
:target: https://pypi.python.org/pypi/SpeechRecognition/
:alt: License
-.. image:: https://img.shields.io/travis/Uberi/speech_recognition.svg
+.. image:: https://api.travis-ci.org/Uberi/speech_recognition.svg?branch=master
:target: https://travis-ci.org/Uberi/speech_recognition
:alt: Continuous Integration Test Results
@@ -329,7 +329,7 @@ Also check out the `Python Baidu Yuyin API <https://github.com/DelightRun/PyBaid
License
-------
-Copyright 2014-2017 `Anthony Zhang (Uberi) <https://uberi.github.io>`__. The source code for this library is available online at `GitHub <https://github.com/Uberi/speech_recognition>`__.
+Copyright 2014-2017 `Anthony Zhang (Uberi) <http://anthony-zhang.me/>`__. The source code for this library is available online at `GitHub <https://github.com/Uberi/speech_recognition>`__.
SpeechRecognition is made available under the 3-clause BSD license. See ``LICENSE.txt`` in the project's `root directory <https://github.com/Uberi/speech_recognition>`__ for more information.
View
@@ -0,0 +1,4 @@
+[bdist_wheel]
+# the `universal` setting means that the project runs unmodified on both Python 2 and 3,
+# and doesn't use any C extensions to Python
+universal=1
@@ -210,12 +210,18 @@ def __enter__(self):
# run the FLAC converter with the FLAC data to get the AIFF data
flac_converter = get_flac_converter()
+ if os.name == "nt": # on Windows, specify that the process is to be started without showing a console window
+ startup_info = subprocess.STARTUPINFO()
+ startup_info.dwFlags |= subprocess.STARTF_USESHOWWINDOW # specify that the wShowWindow field of `startup_info` contains a value
+ startup_info.wShowWindow = subprocess.SW_HIDE # specify that the console window should be hidden
+ else:
+ startup_info = None # default startupinfo
process = subprocess.Popen([
flac_converter,
"--stdout", "--totally-silent", # put the resulting AIFF file in stdout, and make sure it's not mixed with any program output
"--decode", "--force-aiff-format", # decode the FLAC file into an AIFF file
"-", # the input FLAC file contents will be given in stdin
- ], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
+ ], stdin=subprocess.PIPE, stdout=subprocess.PIPE, startupinfo=startup_info)
aiff_data, stderr = process.communicate(flac_data)
aiff_file = io.BytesIO(aiff_data)
try:
@@ -412,12 +418,18 @@ def get_flac_data(self, convert_rate=None, convert_width=None):
# run the FLAC converter with the WAV data to get the FLAC data
wav_data = self.get_wav_data(convert_rate, convert_width)
flac_converter = get_flac_converter()
+ if os.name == "nt": # on Windows, specify that the process is to be started without showing a console window
+ startup_info = subprocess.STARTUPINFO()
+ startup_info.dwFlags |= subprocess.STARTF_USESHOWWINDOW # specify that the wShowWindow field of `startup_info` contains a value
+ startup_info.wShowWindow = subprocess.SW_HIDE # specify that the console window should be hidden
+ else:
+ startup_info = None # default startupinfo
process = subprocess.Popen([
flac_converter,
"--stdout", "--totally-silent", # put the resulting FLAC file in stdout, and make sure it's not mixed with any program output
"--best", # highest level of compression available
"-", # the input FLAC file contents will be given in stdin
- ], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
+ ], stdin=subprocess.PIPE, stdout=subprocess.PIPE, startupinfo=startup_info)
flac_data, stderr = process.communicate(wav_data)
return flac_data

0 comments on commit 695b123

Please sign in to comment.