[python]
import random
import pyttsx3
for r in range (15):
fname = "bjjj.txt"
with open(fname) as f:
numbers = f.readline().strip().split()
# print the numbers in the file:
print(numbers)
for _ in range(1): # loop 15 times
k = str(random.randint(1, 16))
if k not in numbers:
print (f'{k} não EXISTE')
numbers.append(k)
else:
print (f'{k} EXISTE')
with open(fname, 'w') as f: # open file in write mode
f.write(f'{" ".join(numbers)}\n')
# vai ler o ficheiro txt de nome ler
#Instrucoes em https://youtu.be/BtwHAvsNaA8
#import pyttsx3 #pip instal pyttsx3
#le o texto que esta guardado em um arquivo .txt
f = open('C:/Users/José Brito/AppData/Local/Programs/Python/Python39/WORK/ler.txt', 'r', encoding="utf8")
texto = f.read()
texto = 'Saiu o número ', k #não lê o ficheiro
speaker = pyttsx3.init() #inicia serviço biblioteca
voices = speaker.getProperty('voices') #metodo de voz
#ver as vozes instaladas na maquina
for voice in voices:
print(voice, voice.id) #traz os idiomas de voz instalados em sua maquina
speaker.setProperty('voice', voices[1].id) #define a voz padrao, no meu caso o portugues era o[2] (iniciando do zero)
rate = speaker.getProperty('rate') #nao exiuste a voz portuguesa
speaker.setProperty('rate', rate-(200)) #muda velocidade da leitura, quando menor mais lento
print(texto) #escreve o texto na tela
speaker.say(texto) #define o texto que será lido
speaker.runAndWait() #le o texto
f.close() #fecha o modo deleitura do arquivo txt
NOTE NOTE oh
I understand. so it records with indentation.
thank you
import random
import pyttsx3
for r in range (15):
fname = "bjjj.txt"
with open(fname) as f:
numbers = f.readline().strip().split()
# print the numbers in the file:
print(numbers)
for _ in range(1): # loop 15 times
k = str(random.randint(1, 16))
if k not in numbers:
print (f'{k} não EXISTE')
numbers.append(k)
else:
print (f'{k} EXISTE')
with open(fname, 'w') as f: # open file in write mode
f.write(f'{" ".join(numbers)}\n')
# vai ler o ficheiro txt de nome ler
#Instrucoes em https://youtu.be/BtwHAvsNaA8
#import pyttsx3 #pip instal pyttsx3
#le o texto que esta guardado em um arquivo .txt
f = open('C:/Users/José Brito/AppData/Local/Programs/Python/Python39/WORK/ler.txt', 'r', encoding="utf8")
texto = f.read()
texto = 'Saiu o número ', k #não lê o ficheiro
speaker = pyttsx3.init() #inicia serviço biblioteca
voices = speaker.getProperty('voices') #metodo de voz
#ver as vozes instaladas na maquina
for voice in voices:
print(voice, voice.id) #traz os idiomas de voz instalados em sua maquina
speaker.setProperty('voice', voices[1].id) #define a voz padrao, no meu caso o portugues era o[2] (iniciando do zero)
rate = speaker.getProperty('rate') #nao exiuste a voz portuguesa
speaker.setProperty('rate', rate-(200)) #muda velocidade da leitura, quando menor mais lento
print(texto) #escreve o texto na tela
speaker.say(texto) #define o texto que será lido
speaker.runAndWait() #le o texto
f.close() #fecha o modo deleitura do arquivo txt
NOTE NOTE oh
I understand. so it records with indentation.
thank you