f.readlines()は1行ずつ
f.read()は全て
# -*- coding: utf-8 -*-
#! /usr/bin/python3
import boto3
import json
accesskey = ""
secretkey = ""
region = "ap-northeast-1"
f = open('2021-11-04.txt', 'r', encoding='UTF-8')
# data = f.read()
datalist = f.readlines()
for data in datalist:
result = data
str = {
"text":result,
}
with open("speech.json", "w") as f:
json.dump(str, f, ensure_ascii=False)
s3 = boto3.client('s3', aws_access_key_id=accesskey, aws_secret_access_key= secretkey, region_name=region)
filename = "speech.json"
bucket_name = "speech-dnn"
s3.upload_file(filename,bucket_name,filename, ExtraArgs={'ACL':'public-read'})
print("upload {0}".format(filename))
{“text”: “今日イチの雄叫びとガッツポーズが此処まで聞こえてきます\n”}
良いね、あとはラズパイのcron設定