Skip to content

Commit 46f6b6a

Browse files
committed
Move the funasr lp into new folder to avoid format error.
1 parent 7b74cd9 commit 46f6b6a

File tree

5 files changed

+938
-0
lines changed

5 files changed

+938
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
title: Introduction to Automatic Speech Recognition (ASR)
3+
weight: 2
4+
5+
### FIXED, DO NOT MODIFY
6+
layout: learningpathall
7+
---
8+
9+
## What is ASR?
10+
11+
Automatic Speech Recognition [ASR](https://en.wikipedia.org/wiki/Speech_recognition), also known as Speech To Text (STT), is a rapidly evolving technology that enables computers to process and transcribe human speech into written text.
12+
13+
This technology has become deeply integrated into our daily lives, powering applications from virtual assistants to real-time transcription services, many of which are optimized for Arm CPU architecture.
14+
15+
At its core, ASR transforms spoken language into written text. Despite seeming straightforward, ASR is a highly complex process that relies on sophisticated algorithms and machine learning models to accurately interpret the nuances of human speech, including variations in pronunciation, accents, and background noise.
16+
17+
### What are the key applications of ASR?
18+
19+
ASR is used in myriad applications across various domains:
20+
21+
* Virtual Assistants and Chatbots - ASR enables natural language interactions in chatbots and virtual assistants, enhancing customer support, information retrieval, and even entertainment.
22+
Use case: a developer can use ASR to create a voice-controlled chatbot that helps users troubleshoot technical issues or navigate complex software applications.
23+
24+
* Data Analytics and Business Intelligence - Leveraging ASR to analyze customer interactions, such as calls and surveys, to uncover trends and enhance services.
25+
Use case: an app that transcribes customer service calls and applies sentiment analysis to pinpoint areas for improving customer satisfaction.
26+
27+
* ASR-powered Accessibility Tools - Developing ASR-powered tools to enhance accessibility for users with disabilities. Applications include voice-controlled interfaces, real-time captioning, and text-to-speech conversion.
28+
Use case: a developer can create a tool that uses ASR to generate real-time captions for online meetings or presentations, making them accessible to deaf and hard-of-hearing individuals.
29+
30+
* Integrating ASR into Software Development Tools - Enhancing efficiency and productivity by incorporating ASR into development environments. This can include voice commands for code editing, debugging, or version control.
31+
Use case: a developer can build an IDE plugin that enables voice-controlled coding, file navigation, and test execution, streamlining the workflow and reducing reliance on manual input.
32+
33+
* Smart Homes and IoT with ASR - Enhancing convenience with voice control of smart home devices and appliances.
34+
Use case: a voice-activated home automation system that lets users control lighting, temperature, and entertainment systems with natural language commands.
35+
36+
### Challenges in ASR
37+
38+
While the potential applications of ASR are vast and inspiring, it is important to acknowledge the inherent challenges in developing and deploying accurate and reliable ASR systems. These challenges stem from the complexities of human speech, environmental factors, and the intricacies of language itself. These challenges are especially pronounced for Chinese ASR, which must address unique linguistic characteristics such as:
39+
40+
* Complexities of Chinese Language - Mandarin Chinese involves tonal variations where the meaning of a syllable changes depending on its tone, and punctuation is crucial to convey meaning and avoid ambiguity. Accurately recognizing these nuances is essential for understanding spoken Chinese.
41+
42+
* Noise Robustness - ASR systems need to be able to filter out background noise to accurately transcribe speech. This is particularly challenging in noisy environments like crowded streets or busy offices.
43+
44+
* Dialectal Diversity - Chinese encompasses numerous dialects with significant variations in pronunciation and vocabulary. This poses a challenge for ASR systems to generalize across different regions and speakers.
45+
46+
* Homophones - Chinese has a high prevalence of homophones, words that sound alike but have different meanings. Disambiguating these homophones requires understanding the context and semantics of the spoken words.
47+
48+
In the following sections, you will explore a solution that leverages the power of ModelScope and Arm CPUs to deliver efficient and accurate Chinese ASR.
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
---
2+
title: ModelScope - Open-Source Pre-trained AI models hub
3+
weight: 3
4+
5+
### FIXED, DO NOT MODIFY
6+
layout: learningpathall
7+
---
8+
9+
## Before you begin
10+
11+
To follow the instructions for this Learning Path, you will need an Arm-based server running Ubuntu 22.04 LTS or later, with at least 8 cores, 16GB of RAM, and 30GB of disk storage.
12+
13+
## What is ModelScope?
14+
[ModelScope](https://github.com/modelscope/modelscope/) is an open-source platform designed to simplify the integration of AI models into applications. It offers a wide variety of pre-trained models for tasks such as image recognition, natural language processing, and audio analysis. With ModelScope, you can seamlessly integrate these models into your projects using just a few lines of code.
15+
16+
Key benefits of ModelScope:
17+
18+
* Model Diversity - Access a wide range of models for various tasks, including Automatic Speech Recognition (ASR), natural language processing (NLP), and computer vision.
19+
20+
* Ease of Use - ModelScope provides a user-friendly interface and APIs that enable seamless model integration.
21+
22+
* Community Support - Benefit from a vibrant community of developers and researchers who actively contribute to and support ModelScope.
23+
24+
25+
## Arm CPU Acceleration
26+
ModelScope fully supports PyTorch 1.8+ and other machine learning frameworks, enabling efficient deployment on Arm Neoverse CPUs. These CPUs leverage Arm's performance and power efficiency advantages for optimized AI workloads.
27+
28+
Arm offers optimized software and tools, such as Kleidi, to accelerate AI model inference on Arm-based platforms. These enhancements make Arm Neoverse CPUs a powerful choice for deploying ModelScope models on edge devices and other resource-constrained environments.
29+
30+
You can learn more about [Faster PyTorch Inference using Kleidi on Arm Neoverse](https://community.arm.com/arm-community-blogs/b/servers-and-cloud-computing-blog/posts/faster-pytorch-inference-kleidi-arm-neoverse) on the Arm community website.
31+
32+
33+
## Install ModelScope and PyTorch
34+
35+
First, ensure your system is up to date and install the necessary tools and libraries:
36+
37+
```bash
38+
sudo apt-get update -y
39+
sudo apt-get install -y curl git wget python3 python3-pip python3-venv python-is-python3 ffmpeg
40+
```
41+
42+
Create and activate a virtual environment:
43+
```bash
44+
python -m venv venv
45+
source venv/bin/activate
46+
```
47+
48+
In your active virtual environment, install ModelScope:
49+
50+
```bash
51+
pip3 install modelscope
52+
```
53+
54+
Install PyTorch and related dependencies:
55+
```bash
56+
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
57+
pip3 install numpy packaging addict datasets simplejson sortedcontainers transformers ffmpeg
58+
59+
```
60+
{{% notice Note %}}
61+
In this Learning Path you will execute models on the Arm Neoverse CPU, so you will only need to install the PyTorch CPU package.
62+
{{% /notice %}}
63+
64+
## Create a simple example
65+
66+
You can now run an example to understand how to use ModelScope for understanding Chinese semantics.
67+
68+
Chinese writing differs fundamentally from English writing. In Chinese, the relationship between characters and their meanings is somewhat analogous to the distinction between words and phrases in English. Some Chinese characters, like English words, have clear meanings on their own, such as “人” (person), “山” (mountain), and “水” (water).
69+
70+
However, more often, Chinese characters need to be combined with other characters to express more complete meanings, much like phrases in English.
71+
72+
For example:
73+
74+
* “祝福” (blessing) can be broken down into “祝” (wish) and “福” (good fortune).
75+
* “分享” (share) can be broken down into “分” (divide) and “享” (enjoy).
76+
* “生成” (generate) can be broken down into “生” (produce) and “成” (become).
77+
78+
For computers to process Chinese sentences accurately, they must understand the rules governing Chinese characters, vocabulary, and grammar to interpret and express meaning correctly.
79+
80+
In this example, you will use a general-domain Chinese [word segmentation model](https://www.modelscope.cn/models/iic/nlp_structbert_word-segmentation_chinese-base) to break down Chinese sentences into individual words. This segmentation process helps computers analyze and understand Chinese text more effectively by identifying distinct words within a continuous string of characters.
81+
82+
Using a file editor of your choice, copy the code shown below into a file named `segmentation.py`:
83+
84+
```python
85+
from modelscope.pipelines import pipeline
86+
87+
word_segmentation = pipeline (
88+
'word-segmentation',
89+
model='damo/nlp_structbert_word-segmentation_chinese-base'
90+
)
91+
text = '一段新年祝福的文字跟所有人分享'
92+
result = word_segmentation(text)
93+
94+
print(result)
95+
```
96+
97+
This piece of code specifies a model and provides a Chinese sentence for the model to segment.
98+
"A New Year’s greeting message to share with everyone."
99+
100+
Run the model inference on the sample text:
101+
102+
```bash
103+
python3 segmentation.py
104+
```
105+
106+
The output should look like this:
107+
```output
108+
2025-01-28 00:30:29,692 - modelscope - WARNING - Model revision not specified, use revision: v1.0.3
109+
Downloading Model to directory: /home/ubuntu/.cache/modelscope/hub/damo/nlp_structbert_word-segmentation_chinese-base
110+
2025-01-28 00:30:32,828 - modelscope - WARNING - Model revision not specified, use revision: v1.0.3
111+
2025-01-28 00:30:33,332 - modelscope - INFO - initiate model from /home/ubuntu/.cache/modelscope/hub/damo/nlp_structbert_word-segmentation_chinese-base
112+
2025-01-28 00:30:33,333 - modelscope - INFO - initiate model from location /home/ubuntu/.cache/modelscope/hub/damo/nlp_structbert_word-segmentation_chinese-base.
113+
2025-01-28 00:30:33,334 - modelscope - INFO - initialize model from /home/ubuntu/.cache/modelscope/hub/damo/nlp_structbert_word-segmentation_chinese-base
114+
You are using a model of type bert to instantiate a model of type structbert. This is not supported for all configurations of models and can yield errors.
115+
2025-01-28 00:30:35,522 - modelscope - WARNING - No preprocessor field found in cfg.
116+
2025-01-28 00:30:35,522 - modelscope - WARNING - No val key and type key found in preprocessor domain of configuration.json file.
117+
2025-01-28 00:30:35,522 - modelscope - WARNING - Cannot find available config to build preprocessor at mode inference, current config: {'model_dir': '/home/ubuntu/.cache/modelscope/hub/damo/nlp_structbert_word-segmentation_chinese-base'}. trying to build by task and model information.
118+
2025-01-28 00:30:35,527 - modelscope - INFO - cuda is not available, using cpu instead.
119+
2025-01-28 00:30:35,529 - modelscope - WARNING - No preprocessor field found in cfg.
120+
2025-01-28 00:30:35,529 - modelscope - WARNING - No val key and type key found in preprocessor domain of configuration.json file.
121+
2025-01-28 00:30:35,529 - modelscope - WARNING - Cannot find available config to build preprocessor at mode inference, current config: {'model_dir': '/home/ubuntu/.cache/modelscope/hub/damo/nlp_structbert_word-segmentation_chinese-base', 'sequence_length': 512}. trying to build by task and model information.
122+
/home/ubuntu/venv/lib/python3.10/site-packages/transformers/modeling_utils.py:1044: FutureWarning: The `device` argument is deprecated and will be removed in v5 of Transformers.
123+
warnings.warn(
124+
{'output': ['生成', '一', '段', '新年', '祝福', '的', '文字', '跟', '所有', '人', '分享']}
125+
```
126+
127+
The segmentation model has correctly identified the following words:
128+
129+
- 一 (one): This is a numeral.
130+
131+
- 段 (piece): This is a measure word used for text.
132+
133+
- 新年 (New Year): This is a noun phrase meaning "New Year."
134+
135+
- 祝福 (blessings): This is a noun meaning "blessings" or "good wishes."
136+
137+
- 的 (of): This is a possessive particle.
138+
139+
- 文字 (text): This is a noun meaning "text" or "written words."
140+
141+
- 跟 (with): This is a preposition meaning "with."
142+
143+
- 所有 (all): This is a quantifier meaning "all."
144+
145+
- 人 (people): This is a noun meaning "people."
146+
147+
- 分享 (share): This is a verb meaning "to share."
148+
149+
The segmentation model has successfully identified the word boundaries and separated the sentence into meaningful units, which is essential for further natural language processing tasks like machine translation or sentiment analysis.
150+

0 commit comments

Comments
 (0)