0

I have a class with a text to be output as an audio track and a path to a word file to be printed. I have written a method for both problems. I started with the method for the audio output. This one worked without any problems. After that I wrote the other method and installed the package win32com. This method also worked without problems. However, with the first method, now the audio breaks after a second and then an error message appears. When I uninstalled the package, the first method works again. I tried different versions of pypwin32, python-vls and gTTS but the result did not change.

Imports:

import vlc
import time
import os
from gtts import gTTS
from mutagen.mp3 import MP3
from win32com import client

Audio method:

def play(self):
    file_name = 'alarm.mp3'
    gTTS(text=self.text, lang='de', slow=False).save(file_name)
    t = int(MP3(file_name).info.length + 0.5)
    p = vlc.MediaPlayer(file_name)
    p.play()
    time.sleep(t)
    p.stop()
    os.remove(file_name)

Print method:

def print_file(self):
    word = client.Dispatch("Word.Application")
    word.Documents.Open(this.path)
    word.ActiveDocument.PrintOut()
    time.sleep(2)
    word.ActiveDocument.Close()

Error:

[00000201701eea10] mmdevice audio output error: cannot initialize COM (error 0x80010106)
[0000020170299ec0] mmdevice audio output error: cannot initialize COM (error 0x80010106)

Any ideas?

0 Answers0