|
1 |
| -# ChatGPT-Python para Termux |
| 1 | +# ChatGPT-Python for Termux |
2 | 2 | import openai
|
3 | 3 | from gtts import gTTS
|
4 | 4 | import os
|
5 | 5 |
|
6 | 6 | # OPENAI API KEY
|
7 | 7 | openai.api_key = ""
|
8 |
| -# Lista con despedidas comunes para finalizar el ciclo while |
| 8 | +# List with common departures to end the while loop |
9 | 9 | despedida = ["Adios", "adios", "bye", "Bye", "Hasta luego", "hasta luego"]
|
10 | 10 |
|
11 | 11 | while True:
|
12 |
| - # Entrada del usuario y verificacion si la entrada coincide con la lista de despedidas |
| 12 | + # User input and check if the input matches the list of goodbyes |
13 | 13 | usuario = str(input("tu: "))
|
14 | 14 | if usuario in despedida:
|
15 | 15 | break
|
16 | 16 | else:
|
17 | 17 | prompt = (f"{usuario}")
|
18 | 18 |
|
19 |
| - # Obteniendo respuestas usando la API de OpenAI |
| 19 | + # Getting responses using the OpenAI API |
20 | 20 | response = openai.Completion.create(
|
21 | 21 | engine="text-davinci-003",
|
22 | 22 | prompt=prompt,
|
|
25 | 25 |
|
26 | 26 | respuesta = response["choices"][0]["text"]
|
27 | 27 | #print("ChatGPT:", response["choices"][0]["text"])
|
28 |
| - # Convirtiendo texto a audio |
| 28 | + # Converting text to audio |
29 | 29 | texto = str(respuesta)
|
30 | 30 | tts = gTTS(texto, lang="es")
|
31 | 31 | tts.save("audio.mp3")
|
32 |
| - # Mostrando la respuesta en pantalla |
| 32 | + # Displaying the answer on the screen |
33 | 33 | print("ChatGPT: ", respuesta)
|
34 |
| - # Reproduciendo el audio |
| 34 | + # Playing the audio |
35 | 35 | os.system("pulseaudio -D")
|
36 | 36 | os.system("play audio.mp3")
|
37 | 37 | os.system("pulseaudio -k")
|
0 commit comments