Research Article
MyOcrTool: Visualization System for Generating Associative Images of Chinese Characters in Smart Devices
Program Listing 3
Program Listing 3: The program listing of voice playback function.
| Input: text | Output: speech | private static ImageButton yuyinButton; | private TextToSpeech textToSpeech; | @Override | protected void onCreate (Bundle savedInstanceState) { | super.onCreate (savedInstanceState); | setContentView (R.layout.my_scan); | yuyinButton = (ImageButton) findViewById (R.id.yuyinButton); | textToSpeech = new TextToSpeech (this, new TextToSpeech.OnInitListener() { | @Override | public void onInit(int status) { | if (status == textToSpeech.SUCCESS) { | int result = textToSpeech.setLanguage(Locale.CHINA); | if (result! = TextToSpeech.LANG_COUNTRY_AVAILABLE&& result != | TextToSpeech.LANG_AVAILABLE){ | Toast.LENGTH_SHORT).show(); | } | } | } | }); | yuyinButton.setOnClickListener (new View.OnClickListener() { | @Override | public void onClick (View view) { | textToSpeech.speak (status_view_tv_result.getText().toString(), | TextToSpeech.QUEUE_ADD, null); | textToSpeech.setSpeechRate (0.5f); | textToSpeech.setPitch (0.1f); | } | }); | } |
|