3 Shortcuts that Justify Opening Visual Studio

I’ve been working a lot with Visual Studio Code the last couple weeks, but recently made the switch back to Visual Studio Community Edition with Python tools for Visual Studio because of three handy shortcuts and one awesome virtual environment manager.

Those three shortcuts are…

Ctrl+F5
Run without debugging.

This sends your python file to the virtual env you have activated to a terminal right next to your project.
Which on its own is cool and handy, but when you right select your solution then select properties:
properties
You can set it to run whatever file you’re currently editing, which makes hoping around different files as your learning so nice.
currentselection

The next shortcut is…

Alt+Shift+F5
Send file to interactive

This is great for when you’re just learning about a new library and you keep piecing together what you understand into the file.

Just keep hitting Alt+Shift+F5 send it to the interactive mess around in the terminal with the new objects you’ve created then determine the best logic and send it back into your file.

You break something?

Just send it back in… perhaps using our final shortcut:

Ctrl+E, Ctrl+E
Send selected text to interactive

Don’t let the comma throw you off, just selected some text and hit ctrl+e twice to run that code in the REPL. This in conjunction with Alt+Shift+F5 make it so pleasant to work in Visual Studio with Python.

Visual Studio is great and all, but if I need to learn some new library or work through a tutorial the robustness and Experience of Visual Studio is tough to beat.

Oh yeah, not related to shortcuts but still awesome is Virtual Environment Support:
virtualenv
Those env’s I created by right clicking on Environments and selecting new virtual environment.
There is support for both versions of Python and to install just use pip by right clicking on the env and install from pip!

I’ll let this nice video they’ve created break it down:
Skip to 9 minutes in to see the Virtual Env Breakdown

Happy Holidays Everyone!
Snapchat-1802119159214415224

Visual Studio Code Extensions! (Typewriter Sounds)

The last two days I’ve been learning about Visual Studio Code Extensions!

This for all the Node/JavaScript Developers out there.

In the end, writing an extension turned out to be a joy. You basically get to create a little program that changes a tool you use everyday and tweak it to exactly what you want then easily publish this to the world.

I made Typewriter Sounds.
Here’s the Repo and the marketplace link

If you install this plugin, you’ll get typewriter sounds as you begin to edit your markdown file.

All the code is available on GitHub, and the instructions for creating your own extension are available on the well documented Visual Studio Code Extensions website!

I thought I’d share some links and resources to help you get started.

First installing an extension

Extension Overview

A simple example

All examples from the vscode team

How to use the Yo Extension Generator to get started Extensibility Reference Overview

vscode API

A couple more advanced examples:

Search from the editor: https://github.com/SrTobi/code-bing

Ember Cli for VS Code:
https://github.com/felixrieseberg/vsc-ember-cli

Vim Editor Commands for VS Code:
https://github.com/VSCodeVim/Vim

Publish your extension

Create the editor you want!

The Python Meetup celebrated their holiday party at 680 Folsom!
The Python Meetup celebrated their holiday party at 680 Folsom!

Python, Flask, Text to Speech (TTS), Microsoft, Project Oxford!

Microsoft Provides at TTS service API to help hackers bring voice to their applications.

This is an introduction to the technology as well as working sample code for Python34.

Two weeks ago I worked with a number of students to use this service in a Python Web App. Here’s some photos of the guys I worked with:

hackschackers

hackucihackers

If you’re already familiar with Project Oxford feel free to skip the first 3 steps.

It seems like some of the API services are being moved from Bing to under Project Oxford so some of the documentation can be a bit scattered.

I want to point you into the simplest path to make this happen and help trim off some of the overhead that might look daunting at first.

1. We’ll start at the Project Oxford Speech API landing page.

signinsubscribe

2. Then sign in and subscribe:

You can also look at the live demos/documentation to get started and test the capabilities.

mykeys

3. Now that we’re signed up and have access to our keys go ahead and keep that tab open because you’ll need to use you’re own key to get this sample code working.

4. In the meantime there is some important documentation to read over to help familiarize yourself with what’s going on:
(Reminder – this API is still in Beta so expect changes along the way)

First is the overview of the Bing Voice Output API
Make sure to check out all the available voices!

And this is the code that we turned into a tiny flask app

5. Two things that I found most confusing about using this sample code…

What is the clientID?
And
What the heck do you do with the data you get back?

6. So here’s the code we wrote:
Its a tiny flask web app.
Here’s a link to the repository:
https://github.com/timmyreilly/tiny-tts-flask

to run on my machine I execute:


C:\Python34\python.exe app.py

…Because I have Python 2.7 and Python 3.4 on my machine I run it from C:\

7. The clientID doesn’t need to be anything… I found out. So you’ll see at line 13 in the helper.py file client_id is set to ‘nothing’

8. Now what to do with the data you get back…

Well it turns out you can request all sorts of different formats.

You’ll see in the headers declaration of helpers.py


"X-Microsoft-OutputFormat": "riff-8khz-8bit-mono-mulaw",

We’re requesting a specific file type in return with this header and you can set it to a number of different formats.

You’ll see at this documentation all the different available formats: https://www.projectoxford.ai/doc/speech/REST/Output

we changed our format from the mono-pcm to mulaw -> which has to do with audio compression.

Basically we get back a string that we can encode into base 64 trim the edges and send raw to the browser which will be available to play with the audio tag.

You’ll see this at line 46 of helper.py with our get_raw_wav function.

Note:
The body of our request can be edited to get different voices (male/female) different languages, and even different cadences.

This all falls under the Speech Synthesis Markup Language (SSML) you can read more about here:
http://www.w3.org/TR/speech-synthesis/
and how Microsoft uses it here:
https://msdn.microsoft.com/en-us/library/hh361578(v=office.14).aspx

Let me know if you have any questions!
Feel free to submit a pull request or fork this code for your next hackathon!

Happy Thanksgiving massive tree on the panhandle!
Happy Thanksgiving massive tree on the panhandle!