首页 树莓派——备忘录
文章
取消

树莓派——备忘录

备忘录

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import os
import datetime
import wav_recognize

def open_memo():
    memo_directory = "../file/beiwanglu/"
    if not os.path.exists(memo_directory):
        os.makedirs(memo_directory)

    current_time = datetime.datetime.now().strftime("%Y%m%d%H")
    memo_file_path = os.path.join(memo_directory, f"{current_time}.txt")

    if os.path.exists(memo_file_path):
        print(f"Opening existing memo file: {memo_file_path}")
    else:
        with open(memo_file_path, "w") as memo_file:
            print(f"Creating new memo file: {memo_file_path}")

    return memo_file_path

def memorandum():
    file_path = open_memo()
    result = wav_recognize.listen()

    with open(file_path, "w") as memo_file:
        memo_file.write(result)

    print(f"Memo saved to: {file_path}")


def open_memorandum():

    results = memorandum()

本文由作者按照 CC BY 4.0 进行授权