Siêu thị PDFTải ngay đi em, trời tối mất

Thư viện tri thức trực tuyến

Kho tài liệu với 50,000+ tài liệu học thuật

© 2023 Siêu thị PDF - Kho tài liệu học thuật hàng đầu Việt Nam

Hướng dẫn xây dựng ứng dụng trên Android ppsx
MIỄN PHÍ
Số trang
3
Kích thước
65.2 KB
Định dạng
PDF
Lượt xem
785

Hướng dẫn xây dựng ứng dụng trên Android ppsx

Nội dung xem thử

Mô tả chi tiết

Trung tâm Tin học – ĐH KHTN

[Hướng dẫn] Ứng dụng Text-to-Speech trên Android

Trong bài viết này sẽ hướng dẫn xây dựng ứng dụng trên Android có khả năng chuyển từ Text sang Voice (tiếng

Anh). Để xây dựng ứng dụng với tính năng Text-to-Speech, phải tạo Project mới với Android SDK 1.6 trở lên.

Sau đây là các bước thực hiện:

Bước 1: Tạo một Project với tên là MyTextToSpeech.

Bước 2: Thay đổi tập tin res/layout/main.xml với thông tin như sau:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:orientation="vertical"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

>

<EditText android:id="@+id/input_text"

android:text=""

android:layout_width="fill_parent"

android:layout_height="wrap_content"

/>

<Button android:id="@+id/speak_button"

android:text="Speak to me"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

/>

</LinearLayout>

Bước 3: Import những gói thư viện sau vào trong Project:

import android.speech.tts.TextToSpeech;

import android.speech.tts.TextToSpeech.OnInitListener;

Bước 4: Thay đổi nội dung tập tin MyTextToSpeech như sau:

package com.app.MyTextToSpeech;

import android.app.Activity;

import android.content.Intent;

import android.os.Bundle;

import android.speech.tts.TextToSpeech;

import android.speech.tts.TextToSpeech.OnInitListener;

import android.view.View;

import android.view.View.OnClickListener;

import android.widget.Button;

Lập trình Android – http://laptrinhdidong.vnPage 1

Tải ngay đi em, còn do dự, trời tối mất!