Skip to content
This repository has been archived by the owner on Feb 9, 2023. It is now read-only.

Commit

Permalink
Don't hardcode home directory (#156)
Browse files Browse the repository at this point in the history
Fixes #139.
  • Loading branch information
drigz authored Oct 18, 2017
1 parent 0a64297 commit b47767e
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/aiy/_apis/_speech.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
AUDIO_SAMPLE_SIZE = 2 # bytes per sample
AUDIO_SAMPLE_RATE_HZ = 16000

# Expected location of the service credentials file:
SERVICE_CREDENTIALS = os.path.expanduser('~/cloud_speech.json')


_Result = collections.namedtuple('_Result', ['transcript', 'response_audio'])

Expand Down Expand Up @@ -449,11 +452,7 @@ def _log_audio_out(self, frames):
parser.add_argument('file', nargs='?', default='test_speech.raw')
args = parser.parse_args()

if os.path.exists('/home/pi/credentials.json'):
# Legacy fallback: old location of credentials.
req = CloudSpeechRequest('/home/pi/credentials.json')
else:
req = CloudSpeechRequest('/home/pi/cloud_speech.json')
req = CloudSpeechRequest(SERVICE_CREDENTIALS)

with open(args.file, 'rb') as f:
while True:
Expand Down

0 comments on commit b47767e

Please sign in to comment.