1 /*
2 * Copyright (c) 2014-2016 Alibaba Group. All rights reserved.
3 * License-Identifier: Apache-2.0
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License"); you may
6 * not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 */
18
19
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <string.h>
23 #include <stdarg.h>
24
25 #include "aos/kernel.h"
26 #include "netmgr.h"
27 #include "ulog/ulog.h"
28 #include "aiconfig.h"
29 #include "aiagent_common.h"
30 //#include "uvoice_player.h"
31 //#include "uvoice_recorder.h"
32 //#include "uvoice_types.h"
33 #include "ulog/ulog.h"
34 #include "led.h"
35 #include "oled/oled.h"
36 #include "hal_iomux_haas1000.h"
37 #include "aos/hal/gpio.h"
38 #include <vfsdev/gpio_dev.h>
39 #include "player/player.h"
40
41 #define TAG "speech"
42
43
application_start(int argc,char ** argv)44 int application_start(int argc, char **argv)
45 {
46 uint64_t current;
47 int32_t ret = 0;
48 gpio_dev_t gpio_pa_en;
49 struct gpio_io_config gpio_config;
50 gpio_dev_t pa_en_gpio;
51
52 /*Enable extension board PA*/
53 pa_en_gpio.port = HAL_IOMUX_PIN_P2_3; // HAL_IOMUX_PIN_P0_4;
54 pa_en_gpio.config = OUTPUT_OPEN_DRAIN_PULL_UP;
55 hal_gpio_init(&pa_en_gpio);
56 hal_gpio_output_high(&pa_en_gpio);
57
58 aos_set_log_level(AOS_LL_DEBUG);
59 led_switch(LED1_NUM, LED_OFF);
60 led_switch(LED2_NUM, LED_OFF);
61 led_switch(LED3_NUM, LED_OFF);
62
63 oled_init();
64 oled_show(OLED_STR_IDLE);
65
66 /*Init sound driver*/
67 audio_install_codec_driver();
68
69 /*Init uvoice*/
70 ret = uvoice_init();
71 if (ret < 0) {
72 LOGE(TAG, "uvoice_init failed !\n");
73 return -1;
74 }
75 /*Init player*/
76 player_init(NULL);
77
78 player_play(PLAYER_MP3_WELCOME);
79 // player_wait_complete();
80 /*Init tflite-micro speech engine*/
81 setup();
82
83 while (1) {
84 loop();
85 };
86
87 return 0;
88 }
89