Python code for text editing or api requests

DonDemon

Member
The ability to request an api through Python code could make requests easier to use due to already created Python codes by developers for their apies
 

Josué García

MacroDroid Support
Staff member
The ability to request an api through Python code could make requests easier to use due to already created Python codes by developers for their apies
Currently MacroDroid supports the import of cURL (string) in the "HTTP Request" action, most APIs also include this cURL code, it may be a good alternative for your main objective.
 

DonDemon

Member
Currently MacroDroid supports the import of cURL (string) in the "HTTP Request" action, most APIs also include this cURL code, it may be a good alternative for your main objective.

I tried to import this python example as cURL
```
import requests openai_api_key = 'ADD YOUR KEY HERE' file_path = '/path/to/file/audio.mp3' # Add the Path of your audio file headers = { 'Authorization': f'Bearer {openai_api_key}', } files = { 'file': open(file_path, 'rb'), 'model': (None, 'whisper-1'), }
```
and nothing happened
 

Josué García

MacroDroid Support
Staff member
I tried to import this python example as cURL
```
import requests openai_api_key = 'ADD YOUR KEY HERE' file_path = '/path/to/file/audio.mp3' # Add the Path of your audio file headers = { 'Authorization': f'Bearer {openai_api_key}', } files = { 'file': open(file_path, 'rb'), 'model': (None, 'whisper-1'), }
```
and nothing happened
On the same Open AI page, apart from the Python demo code, it also shows you the code option in cURL
 

Dimlos

Well-known member
The API can be accessed with the HTTP Request Shortcuts application.

1.Install HTTP Request Shortcuts.

2.Import openai_shortcut.zip.

3.Select Hello World.MP3(Unzip Hello World.zip) in the Request Body/Parameters file.

4.Import OpenAI_Speech_to_text.macro.

5.Set the local variable openai_api_key.

6.Edit Actions and re-select OpenAI_Speech_to_text.

7.Execute the macro.
 

Attachments

  • macro.jpg
    macro.jpg
    207.8 KB · Views: 5
  • settings.jpg
    settings.jpg
    132.3 KB · Views: 5
  • openai_shortcut.zip
    867 bytes · Views: 0
  • Hello World.zip
    4.4 KB · Views: 0
  • OpenAI_Speech_to_text.macro
    5.1 KB · Views: 0

DonDemon

Member
The API can be accessed with the HTTP Request Shortcuts application.

1.Install HTTP Request Shortcuts.

2.Import openai_shortcut.zip.

3.Select Hello World.MP3(Unzip Hello World.zip) in the Request Body/Parameters file.

4.Import OpenAI_Speech_to_text.macro.

5.Set the local variable openai_api_key.

6.Edit Actions and re-select OpenAI_Speech_to_text.

7.Execute the macro.
thanks
 

DonDemon

Member
The API can be accessed with the HTTP Request Shortcuts application.

1.Install HTTP Request Shortcuts.

2.Import openai_shortcut.zip.

3.Select Hello World.MP3(Unzip Hello World.zip) in the Request Body/Parameters file.

4.Import OpenAI_Speech_to_text.macro.

5.Set the local variable openai_api_key.

6.Edit Actions and re-select OpenAI_Speech_to_text.

7.Execute the macro.
How to port api with this methods?
 

Attachments

  • SmartSelect_20240401_162910_Samsung Internet.png
    SmartSelect_20240401_162910_Samsung Internet.png
    100.3 KB · Views: 6

Dimlos

Well-known member
I assembled it myself using cURL as a reference.
I don't think a simple conversion would work.
 
Top