• 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
            self.__synthesizer.speakUtterance_(utterance)
    
        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):
            self.__synthesizer.continueSpeaking()
    
    

    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)
    
    time.sleep(1)
    speech_.stop()
    print(speech_.is_speaking())
    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
    
    speech.say(some_russian_text)
    

    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
    
    speech.say('hello')
    
    

    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
    clipboard.set('{}'.format(n3))
    
    

    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"
    webbrowser.open(url)
    

    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:
      clipboard.set(f.read())
    webbrowser.open('shortcuts://run-shortcut?name=my_shortcut&input=clipboard')
    
    # 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
  • sulcud

    What is the content of that file? Latitude, longitude? I check that the url scheme can recieve
    gaiagps://map?lat=value&lng=value&z=value

    posted in Pythonista read more
  • sulcud

    do you want to copy a file to gaiagps?
    Sorry but I don’t understand your question

    posted in Pythonista read more
  • sulcud

    You can see this for more help

    Documentation

    posted in Pythonista read more
  • sulcud

    It is easy, put the extension.py and the main.py file in a folder with a file called __init__.py, them in the main.py

    import extension
    extension.your_function()
    

    I hope this work for you

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!