Skip to content

Commit

Permalink
Fix the module imports to provide Python 3 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
mertyildiran committed Apr 22, 2018
1 parent a54da40 commit fbbffb5
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 6 deletions.
14 changes: 12 additions & 2 deletions dragonfire/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,24 @@

import argparse
import contextlib
import cStringIO

try:
import StringIO
except ImportError:
import io as StringIO

import datetime
import inspect
import os
import re
import subprocess
import sys
import thread

try:
import thread
except ImportError:
import _thread as thread

import time
import uuid
from multiprocessing import Event, Process
Expand Down
7 changes: 6 additions & 1 deletion dragonfire/omniscient.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

import collections # Imported to support ordered dictionaries in Python
import contextlib
import cStringIO

try:
import StringIO
except ImportError:
import io as StringIO

import random
import sys

Expand Down
6 changes: 4 additions & 2 deletions dragonfire/sr/deepspeech/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from threading import Thread

import pyaudio # Provides Python bindings for PortAudio, the cross platform audio API
#from dragonfire import VirtualAssistant
#from dragonfire import VirtualAssistant TODO: Add Python 3 support project-wide

from config import ConfigDeepSpeech
from server import SpeechServerMain
Expand Down Expand Up @@ -84,11 +84,13 @@ def recognize(self, args):

print("Analyzing...")
stream.stop_stream()
stream.start_stream()
audio = np.fromstring(audio, dtype=np.int16) # Fix data type
com = SpeechServerMain.ds.stt(audio, RATE)
stream.start_stream()
print(com)

self.reset()

data = stream.read(CHUNK) # Read a new chunk from the stream
if LISTENING:
stream.write(data, CHUNK)
Expand Down
11 changes: 10 additions & 1 deletion dragonfire/stray.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
from __future__ import print_function
import wx
import os
try:
import wx.adv
except:
pass

TRAY_TOOLTIP = 'System Tray Demo'
TRAY_ICON = '/usr/share/icons/hicolor/48x48/apps/dragonfire_icon.png'
Expand All @@ -9,6 +13,11 @@
os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir)) + '/'
global_event_holder = ''

try:
TBI = wx.TaskBarIcon
except AttributeError:
TBI = wx.adv.TaskBarIcon


def create_menu_item(menu, label, func):
item = wx.MenuItem(menu, -1, label)
Expand All @@ -17,7 +26,7 @@ def create_menu_item(menu, label, func):
return item


class TaskBarIcon(wx.TaskBarIcon):
class TaskBarIcon(TBI):
def __init__(self, frame):
self.frame = frame
super(TaskBarIcon, self).__init__()
Expand Down

0 comments on commit fbbffb5

Please sign in to comment.