• sulcud

    PyCharm could be a good alternative

    posted in Pythonista read more
  • sulcud

    Up to date pre-installed modules

    posted in Pythonista read more
  • sulcud

    I think that erasing a Pythonista build-in module is not possible, remember that python has a weird importing system so if you have a script/folder called speech in the same folder of your main script maybe you are importing it instead of the build in one. (python import order is: current dir, ... , site-packages, build-in) but If that is not the case, I think a fresh install of Pythonista could work

    posted in Pythonista read more
  • sulcud

    @cvp, you are right, using 0 fixes it, did you find anyway to fix the false positives that is_paused and is_speaking functions return?

    posted in Pythonista read more
  • sulcud

    @lyubomyr83, I made this class to make it easier to work with the reference @ccc is pointing to, all could be done thanks to the work of @JonB

    import objc_util
    import re
    class SpeechModule(object):
        def __init__(self):
            self.__AVSpeechUtterance = objc_util.ObjCClass('AVSpeechUtterance')
            self.__AVSpeechSynthesizer = objc_util.ObjCClass('AVSpeechSynthesizer')
            self.__AVSpeechSynthesisVoice = objc_util.ObjCClass('AVSpeechSynthesisVoice')
            self.__synthesizer = self.__AVSpeechSynthesizer.new()
        def get_synthesis_languages(self) -> list:
            return self.__AVSpeechSynthesisVoice.speechVoices()
        def say(self, msg: str, language: objc_util.ObjCInstance, rate=0.5):
            utterance = self.__AVSpeechUtterance.speechUtteranceWithString_(msg)
            utterance.rate = rate
            utterance.voice = voice
            utterance.useCompactVoice = False
        def is_speaking(self) -> bool:
            return self.__synthesizer.isSpeaking()
        def is_paused(self) -> bool:
            return self.__synthesizer.isPaused()
        def pause(self) -> bool:
            return self.__synthesizer.pauseSpeakingAtBoundary_(True)
        def stop(self) -> bool:
            return self.__synthesizer.stopSpeakingAtBoundary_(True)
        def continue_speaking(self):

    Here is an example how to use it

    import time
    speech_ = SpeechModule()
    available_voices = speech_.get_synthesis_languages()
    us_english_voices = tuple(filter(lambda voice: "en-US" in str(voice), available_voices))
    voice = us_english_voices[0]
    speech_.say('Hello friend! how are you?', voice, 0.3)
    speech_.say("nevermind", voice)

    For some reason I can’t make that pause function to work correctly, anyway, it is an idea for your project and maybe my class could be buggy, so objc gurus invocation (@cvp @mikael @JonB @ccc )

    posted in Pythonista read more
  • sulcud

    I don’t speak Russian so I can’t confirm is the Russian pronunciation Is wrong, but maybe you are running the “say” function with the language “en-US”; this function has this parameters:

    text -> text you want to say
    language -> (optional) the language that you want to speak with
    rate -> (optional) the speed of the voice

    Maybe you are trying this, I don’t know

    import speech

    You should try

    import speech
    speech.say("привет друг", "ru-RU")

    posted in Pythonista read more
  • sulcud

    This is not a solution for the installation but maybe it can help you, Pythonista has an already TTS module called “speech” and it works well

    import speech

    posted in Pythonista read more
  • sulcud

    Hello @Enez-Houad, you're solution is good, the clipboard is a good way to share information Pythonista => shortcuts the only two problems I saw in your scripts are first you are not setting the values to your clip board you can do it with:

    import clipboard
    import sys, webbrowser
    n1, n2 = int(sys.argv[1]), int(sys.argv[2])
    n3 = n1 + n2
    # I don't know what variable you want to use n1,n2 or n3?
    # This set the value n3 to the device clipboard

    Second you need a shortcut that can wrap your clipboard, the shortcuts app have a variable with that function, and with it you can use the correct url scheme

    # this will open your shortcut with as input the device clipboard
    url = "shortcuts://run-shortcut?name=[ShortcutName]&input=clipboard"

    shortcuts url scheme
    Pythonista clipboard

    example of the shortcut

    posted in Pythonista read more
  • sulcud

    @cvp said:

    @djl this works, tested with another app because I don't have gaiagps

    import webbrowser
    import clipboard
    with open(file_path,'rt',encoding='utf-8') as f:
    # my_shortcut only contains one command: open in one app

    Probably this is the simplest answer to your question
    But you are right, I download the app and I try that shortcut with that app, and the shortcut app create a txt file with the content of the original file

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!