It should be as simple as this.
function custom_sub_field_excerpt($field) {
$text = get_sub_field($field);
// the rest of your code
}
You also don’t need to use global $post;
in your case since your not using it for anything and ACF automatically does this if you don’t supply a post ID when getting the value of a field.